Method: DatePart for VBS
- Updated2024-09-12
- 2 minute(s) read
Methods > Method: DatePart for VBS
Method: DatePart for VBS
Specifies the given part of a date.
vDatePart = Object.DatePart(interval, Date, [firstdayofweek], [firstdayofyear])
Object | VBS Object with this method. You do not need to specify this object. | ||||||||||||||||||||
interval | Variant Specifies the timespan to be determined by the DatePart method. The following settings are possible.
| ||||||||||||||||||||
Date | Variant 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. | ||||||||||||||||||||
vDatePart | Variant 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))