The VBA WeekdayName Function returns a string containing the weekday name, for a supplied integer representation of a weekday.
The syntax of the function is:
Where the function arguments are:
Weekday | - |
An integer, between 1 and 7, representing the day of the week. (Note that the weekday that is represented by each integer value depends on the value of the [FirstDayOfWeek] argument). |
||||||||||||||||||||||||
[Abbreviate] | - |
An optional Boolean argument that specifies whether the returned weekday name should be abbreviated. This can have the value:
|
||||||||||||||||||||||||
[FirstDayOfWeek] | - |
An optional FirstDayOfWeek enumeration value, specifying the weekday that should be used as the first day of the week. This can have any of the following values:
If omitted, the [FirstDayOfWeek] argument uses the default value vbSunday. |
' Return the weekday name for weekday number 1
' (first day of week set to different values)
Dim wkday1 As String
Dim wkday2 As String Dim wkday3 As String
wkday1 = WeekdayName( 1 )
' wkday1 is now equal to the string "Sunday".
wkday2 = WeekdayName( 1, True )
wkday3 = WeekdayName( 1, True, vbMonday )' wkday2 is now equal to the string "Sun". ' wkday3 is now equal to the string "Mon". |
Note that, in the above examples:
Therefore, after running the example code, the variables wkday1, wkday2 and wkday3 are equal to the Strings "Sunday", "Sun" and "Mon" respectively.
' Return the weekday name for the date 12/31/2015
Dim wkday As String
' The variable wkday now equals "Thursday".
wkday = WeekdayName( Weekday( #12/31/2015# ) ) |
The above VBA code combines the WeekdayName function with the Weekday function, to return the weekday name for the date 12/31/2015.
Therefore, after running the above VBA code, the variable wkday is equal to the String "Thursday".