Visual Basic Language Reference  

WeekdayName Function

Returns a String value containing the name of the specified weekday.

Public Function WeekdayName( _
   ByVal WeekDay As Integer, _
   Optional ByVal Abbreviate As Boolean = False, _
   Optional ByVal FirstDayOfWeekValue As FirstDayOfWeek = FirstDayOfWeek.System _
) As String

Parameters

WeekDay
Required. Integer. The numeric designation for the weekday, from 1 through 7; 1 indicates the first day of the week and 7 indicates the last day of the week. The identities of the first and last days depend on the setting of FirstDayOfWeekValue.
Abbreviate
Optional. Boolean value that indicates if the weekday name is to be abbreviated. If omitted, the default is False, which means the weekday name is not abbreviated.
FirstDayOfWeekValue
Optional. A value chosen from the FirstDayOfWeek enumeration that specifies the first day of the week. If not specified, FirstDayOfWeek.System is used.

Settings

The FirstDayOfWeekValue argument can have one of the following settings.

Enumeration value Value Description
FirstDayOfWeek.System 0 First day of week specified in system settings (default)
FirstDayOfWeek.Sunday 1 Sunday
FirstDayOfWeek.Monday 2 Monday (complies with ISO standard 8601, section 3.17)
FirstDayOfWeek.Tuesday 3 Tuesday
FirstDayOfWeek.Wednesday 4 Wednesday
FirstDayOfWeek.Thursday 5 Thursday
FirstDayOfWeek.Friday 6 Friday
FirstDayOfWeek.Saturday 7 Saturday

Exceptions/Errors

Exception type Error number Condition
ArgumentException 5 WeekDay is less than 1 or greater than 7, or FirstDayOfWeekValue is less than 0 or greater than 7.

Remarks

The string returned by WeekdayName depends not only on the input arguments, but also on the Regional Options settings specified in the Windows Control Panel.

If WeekDay is less than 1 or more than 7, or if FirstDayOfWeekValue is less than 0 or more than 7, an ArgumentException error occurs.

Note   WeekdayName uses the current calendar setting from the CurrentCulture property of the CultureInfo class in the System.Globalization namespace. The default CurrentCulture values are determined by Control Panel settings.

See Also

MonthName Function | System Namespace | System.Globalization Namespace | DateTime Structure | ArgumentException Class | CultureInfo Class