And Time. Weekday(DateTime, FirstDayOfWeek) Method
Returns an integer value containing a number representing the day of the week.
public static int Weekday (DateTime DateValue, Microsoft.VisualBasic.FirstDayOfWeek DayOfWeek = Microsoft.VisualBasic.FirstDayOfWeek.Sunday);
static member Weekday : DateTime * Microsoft.VisualBasic.FirstDayOfWeek -> int
Public Function Weekday (DateValue As DateTime, Optional DayOfWeek As FirstDayOfWeek = Microsoft.VisualBasic.FirstDayOfWeek.Sunday) As Integer
Date value for which you want to determine the day of the week.
An integer value containing a number representing the day of the week.
DayOfWeek is less than 0 or more than 7.
The following example uses the
Weekday function to obtain the day of the week from a specified date.
Dim oldDate As Date Dim oldWeekDay As Integer oldDate = #2/12/1969# oldWeekDay = Weekday(oldDate) ' oldWeekDay now contains 4 because thisDate represents a Wednesday.
The value returned by the
Weekday function corresponds to the values of the
FirstDayOfWeek enumeration; that is, 1 indicates Sunday and 7 indicates Saturday.
Weekday 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.
DayOfWeek argument can have one of the following settings.
||0||First day of week specified in system settings|
||2||Monday (complies with ISO standard 8601, section 3.17)|