The VBA WeekdayName Function

Related Function:
VBA Weekday


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:

WeekdayName( Weekday, [Abbreviate], [FirstDayOfWeek] )

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:

True - Return abbreviated weekday name (i.e. "Sun", "Mon", "Tue", etc.)
False - Return full weekday name (i.e. "Sunday", "Monday", "Tuesday", etc.)
If the [Abbreviate] argument is omitted, it is set to the default value False.
[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:

vbUseSystemDayOfWeek - The first day of the week is as specified in your system settings
vbSunday - Sunday
vbMonday - Monday
vbTuesday - Tuesday
vbWednesday - Wednesday
vbThursday - Thursday
vbFriday - Friday
vbSaturday - Saturday

If omitted, the [FirstDayOfWeek] argument uses the default value vbSunday.

VBA WeekdayName Function Examples

Example 1 - Return the Weekday Name for a Given Weekday Number

' 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 )
' wkday2 is now equal to the string "Sun".
wkday3 = WeekdayName( 1, True, vbMonday )
' 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.

Example 2 - Return the Weekday Name for a Given Date

' Return the weekday name for the date 12/31/2015
Dim wkday As String
wkday = WeekdayName( Weekday( #12/31/2015# ) )
' The variable wkday now equals "Thursday".

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".