
226
|
Chapter 12: The Language Reference
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
If omitted,
Jan1 is used.
Description
The DatePart function returns an individual component of the date or time (such as
the month or the second) from a date or time value.
Usage at a Glance
• DatePart replicates the functionality of the distinct Year, Month, Day, Hour, Minute,
and
Second functions.
• You can check that a date expression is valid using the IsDate function.
Version Differences
• VB 6 lacks the DateInterval enumeration and therefore only accepts a string as the
interval argument.
• VB 6 supports a number of constants beginning with vb... (such as vbSunday)as
values for the
firstDayOfWeekValue and firstWeekOfYearValue arguments. While
these are still supported in .NET, the new FirstDayOfWeek and FirstWeekOfYear
enumerations are preferred.
See Also
DateSerial Function, DateString Property, DateValue Function
DateSerial Function
Class
Microsoft.VisualBasic.DateAndTime
Syntax
Dim result As Date = DateSerial(year, month, day)
year (required; Integer)
The year, a number between 1 and 9999, inclusive
month (required; Integer)
The month, a number between 1 and 12, inclusive
day (required; Integer)
The day, a number between 1 and 31, inclusive
Description
The DateSerial function returns a Date with the value that is specified by the three
date components.