Easy Tutorial
❮ Vbscript Examples Func Len ❯

VBScript DatePart Function



The DatePart function returns a specified part of a given date.

Syntax

Parameter Description
interval Required. The time interval to return. Possible values are: yyyy - Year<br> q - Quarter<br> m - Month<br> y - Day of the year<br> d - Day<br> w - Day of the week<br> ww - Week of the year<br> h - Hour<br> n - Minute<br> s - Second
date Required. The date expression to evaluate.
firstdayofweek Optional. Specifies the day of the week. Possible values are: 0 = vbUseSystemDayOfWeek - Use NLS API setting<br> 1 = vbSunday - Sunday (default)<br> 2 = vbMonday - Monday<br> 3 = vbTuesday - Tuesday<br> 4 = vbWednesday - Wednesday<br> 5 = vbThursday - Thursday<br> 6 = vbFriday - Friday<br> 7 = vbSaturday - Saturday
firstweekofyear Optional. Specifies the first week of the year. Possible values are: 0 = vbUseSystem - Use NLS API setting<br> 1 = vbFirstJan1 - Starts with the week containing January 1 (default)<br> 2 = vbFirstFourDays - Starts with the first week that has at least four days in the new year<br> 3 = vbFirstFullWeek - Starts with the first full week in the new year

Example

Example 1

Retrieve the month from a date:

Output of the above example:

Example 2

Get the current month:

Output of the above example:

Example 3

Get the hour:

Output of the above example:


❮ Vbscript Examples Func Len ❯