DIAdem Help

Content Type
Programming Language
Current manual
Table of Contents

Method: DatePart for VBS

Method: DatePart for VBS

Specifies the given part of a date.

vDatePart = Object.DatePart(interval, Date, [firstdayofweek], [firstdayofyear])
ObjectVBS
Object with this method. You do not need to specify this object.
intervalVariant
Specifies the timespan to be determined by the DatePart method. The following settings are possible.
"yyyy"Year
"q" Quarter
"m" Month
"y" Day of the year
"d" Day
"w" Weekday
"ww" Week of the year
"h" Hour
"n" Minute
"s" Second
DateVariant
Specifies the date. If you do not enter the year, the DatePart method uses the current year.
[firstdayofweek]Variant
Specifies the weekday. Possible values are vbSunday, vbMonday, vbTuesday, vbWednesday, vbThursday, vbFriday, vbSaturday and vbUseSystem. If you do not enter a value, the DatePart method uses Sunday. This setting only considers the method for the "w" and "ww" timespans.
[firstdayofyear]Variant
Specifies the first week of the year. Possible values are vbFirstJan1, vbFirstFourDays, vbFirstFullWeek and vbUseSystem. If you do not enter a value, the DatePart method uses January 1.
vDatePartVariant
Receives the number of timespans.

The following example returns various timespans:

Call MsgBox("Quarter :" & DatePart("q", Now))
Call MsgBox("Day of year :" & DatePart("y", Now))
Call MsgBox("Week of year :" & DatePart("ww", Now))
In This Section
Was this information helpful?