Export (0) Print
Expand All

WeekdayName Function (Visual Basic)

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

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.

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

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.

See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the Number Property (Err Object).) However, when possible, you should consider replacing such error control with Structured Exception Handling Overview for Visual Basic.

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.

NoteNote:

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.

The following example uses the Weekday function to obtain the day of the week from a specified date, and then the WeekDayName function to obtain the name of the weekday from its number.

Dim oldDate As Date 
Dim oldWeekDayName As String
oldDate = #2/12/1969#
oldWeekDayName = WeekdayName(Weekday(oldDate))
' oldWeekDayName now contains "Wednesday".

Namespace: Microsoft.VisualBasic

Module: DateAndTime

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Community Additions

ADD
Show:
© 2014 Microsoft