Szerkesztés

Megosztás a következőn keresztül:


DateAndTime.WeekdayName(Int32, Boolean, FirstDayOfWeek) Method

Definition

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

public static string WeekdayName (int Weekday, bool Abbreviate = false, Microsoft.VisualBasic.FirstDayOfWeek FirstDayOfWeekValue = Microsoft.VisualBasic.FirstDayOfWeek.System);
static member WeekdayName : int * bool * Microsoft.VisualBasic.FirstDayOfWeek -> string
Public Function WeekdayName (Weekday As Integer, Optional Abbreviate As Boolean = false, Optional FirstDayOfWeekValue As FirstDayOfWeek = Microsoft.VisualBasic.FirstDayOfWeek.System) As String

Parameters

Weekday
Int32

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
Boolean

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
FirstDayOfWeek

Optional. A value chosen from the FirstDayOfWeek enumeration that specifies the first day of the week. If not specified, FirstDayOfWeek.System is used.

Returns

A string value containing the name of the specified weekday.

Exceptions

Weekday is less than 1 or greater than 7, or FirstDayOfWeekValue is less than 0 or greater than 7.

Examples

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

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.

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.

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

Applies to

See also