Name
DatePart Function — Microsoft.VisualBasic.DateAndTime
Synopsis
DatePart(interval,datevalue[,firstdayofweekvalue[, _firstweekofyearvalue]])
intervalrequired; String orDateIntervalenumDefines the part of the date/time to extract from
datevaluedatevaluerequired; Date, or an expression capable of conversion to a dateThe Date value to evaluate
firstdayofweekvalueoptional;FirstDayOfWeekenumA member of the
FirstDayOfWeekenumfirstweekofyearvalueoptional;FirstWeekOfYearenumA member of the
FirstWeekOfYearenum
Return Value
An Integer containing the specified part
Description
Extracts an individual component of the date or time (like the month or the second) from a date/time value. The DatePart function returns an Integer containing the specified portion of the given date. DatePart is a single function encapsulating the individual Year, Month, Day, Hour, Minute, and Second functions.
interval can be one of the following
literal strings:
|
|
Year |
|
|
Quarter |
|
|
Month |
|
|
Day of year |
|
|
Day |
|
|
Weekday |
|
|
Week |
|
|
Hour |
|
|
Minute |
|
|
Second |
interval can also be a member of the
DateInterval enum:
Enum DateInterval Day DayOfYear Hour Minute Month Quarter Second Week Weekday WeekOfYear End Enum
The firstdayofweekvalue argument can be
any of the following members of the FirstDayOfWeek
enumeration:
Enum FirstDayOfWeek
System 'uses first day of week
'setting on local system
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
End EnumThe firstdayofweekvalue argument affects ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access