Returns the specified part of a given date.
Date DatePart(String interval, Date date, [Integer firstdayofweek], [Integer firstweekofyear])
|interval||(String) Specifies the part of date that will be returned::|
yyyy - year
q - quarter
m - month
y - day of year
d - day
w - day of the week
ww - week of year
h - hour
n - minute
s - second
|date||(Date) Date to evaluate|
|firstdayofweek||[optional] (Integer) Specifies day of the week. If not set, then Sunday is assumed. Values see VBScript Date and Time constants.|
|firstweekofyear||[optional] (Integer) Specifies the first week of year. If not set, then the first week is assumed to be the week in which 1st January occurs. Values see VBScript Date and Time constants.|
You can use the function to evaluate a date and return a specific interval of time. For example, you might use function to calculate the day of the week or the current hour. The firstdayofweek argument affects calculations that use the "w" and "ww" interval symbols.
If date is a date literal, then the specified year becomes a permanent part of that date. However, if date is enclosed in quotation marks (" "), and you omit the year, then the current year is inserted in your script each time the date expression is evaluated. This makes it possible to write script that can be used in different years.
VBScriptSelect and copy to clipboard
d = DatePart("h",