Weekday
Synopsis
Weekday(weekday[,firstdayofweek])
Arguments
weekday | Any expression that can represent a date. |
firstdayofweek | Optional — A constant that specifies the first day of the week. If omitted, vbSunday is assumed. See Description section for values. |
Description
The Weekday function returns an integer between 1 and 7 (inclusive) specifying the day of the week represented by weekday. The first day of the week is, by default, Sunday, or the current NLS day of week setting overriding this default system-wide.
The firstdayofweek argument can be used to set the first day of the week for this statement to the day of your choosing. The firstdayofweek argument can have the following values:
Constant | Value | Description |
---|---|---|
vbUseSystem | 0 | Use National Language Support (NLS) API setting. |
vbSunday | 1 | Sunday |
vbMonday | 2 | Monday |
vbTuesday | 3 | Tuesday |
vbWednesday | 4 | Wednesday |
vbThursday | 5 | Thursday |
vbFriday | 6 | Friday |
vbSaturday | 7 | Saturday |
The Weekday function can return any of these values:
Constant | Value | Description |
---|---|---|
vbSunday | 1 | Sunday |
vbMonday | 2 | Monday |
vbTuesday | 3 | Tuesday |
vbWednesday | 4 | Wednesday |
vbThursday | 5 | Thursday |
vbFriday | 6 | Friday |
vbSaturday | 7 | Saturday |
Examples
The following example uses the Weekday function to obtain the default day of the week for the specified date:
MyDay0 = Weekday("11/1/2005")
Println MyDay0
Nov. 1, 2005 is a Tuesday, so Weekday("11/1/2005") returns 3.
The following example shows the effects of the firstdayofweek argument:
MyDay1 = Weekday("11/1/2005",vbSunday)
MyDay2 = Weekday("11/1/2005",vbMonday)
MyDay3 = Weekday("11/1/2005",vbTuesday)
MyDay4 = Weekday("11/1/2005",vbWednesday)
MyDay5 = Weekday("11/1/2005",vbThursday)
MyDay6 = Weekday("11/1/2005",vbFriday)
MyDay7 = Weekday("11/1/2005",vbSaturday)
Println "Day is: ",MyDay1," Week begins Sunday"
Println "Day is: ",MyDay2," Week begins Monday"
Println "Day is: ",MyDay3," Week begins Tuesday"
Println "Day is: ",MyDay4," Week begins Wednesday"
Println "Day is: ",MyDay5," Week begins Thursday"
Println "Day is: ",MyDay6," Week begins Friday"
Println "Day is: ",MyDay7," Week begins Saturday"