Export (0) Print
Expand All

DateAndTime.Weekday Method

Returns an Integer value containing a number representing the day of the week.

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static int Weekday(
	DateTime DateValue,
	FirstDayOfWeek DayOfWeek
)

Parameters

DateValue
Type: System.DateTime
Required. Date value for which you want to determine the day of the week.
DayOfWeek
Type: Microsoft.VisualBasic.FirstDayOfWeek
Optional. A value chosen from the FirstDayOfWeek enumeration that specifies the first day of the week. If not specified, FirstDayOfWeek.Sunday is used.

Return Value

Type: System.Int32
Returns an Integer value containing a number representing the day of the week.

ExceptionCondition
ArgumentException

DayOfWeek is less than 0 or more than 7.

The value returned by the Weekday function corresponds to the values of the FirstDayOfWeek enumeration; that is, 1 indicates Sunday and 7 indicates Saturday.

NoteNote

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.

The DayOfWeek argument can have one of the following settings.

Enumeration value

Value

Description

FirstDayOfWeek.System

0

First day of week specified in system settings

FirstDayOfWeek.Sunday

1

Sunday (default)

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

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.


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft