Name
Weekday Function
Syntax
Weekday(date, [firstdayofweek])
dateUse: Required
Data Type: Variant
Any valid date expression.
firstdayofweekUse: Optional
Data Type: Integer
Integer specifying the first day of the week.
Return Value
An Integer.
Description
Determines the day of the week of a given date.
Rules at a Glance
The following intrinsic VBScript constants determine the value returned by the Weekday function:
Constant | Return value | Day represented |
| 1 | Sunday |
| 2 | Monday |
| 3 | Tuesday |
| 4 | Wednesday |
| 5 | Thursday |
| 6 | Friday |
| 7 | Saturday |
If
dateisNull, the Weekday function also returnsNull.The following table describes the settings for the
firstdayofweekargument:
Constant | Value | Description |
vbUseSystem | 0 | Use the NLS API setting |
vbSunday | 1 | Sunday (default) |
vbMonday | 2 | Monday |
vbTuesday | 3 | Tuesday |
vbWednesday | 4 | Wednesday |
vbThursday | 5 | Thursday |
vbFriday | 6 | Friday |
vbSaturday | 7 | Saturday |
Programming Tips and Gotchas
If you specify a
firstdayofweekargument, the function returns the day of the week relative tofirstdayofweek. For instance, if you set the value offirstdayofweektovbMonday(2), indicating that Monday is the first day of the week, and attempt to determine the day of the week on which October 1, 1996, falls, the function returns a 2. That’s because October 1, 1996, is a Tuesday, the second day of a week whose first day is Monday.Because the function’s return value is relative to
firstdayofweek, using the day of the week constants to interpret the function’s return value ...
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