DateTimeOffset.DayOfWeek Property

Gets the day of the week represented by the current DateTimeOffset object.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Public ReadOnly Property DayOfWeek As DayOfWeek

Property Value

Type: System.DayOfWeek
One of the enumeration values that indicates the day of the week of the current DateTimeOffset object.

The value of the constants in the DayOfWeek enumeration ranges from DayOfWeek.Sunday to DayOfWeek.Saturday. If cast to an integer, its value ranges from zero (indicating DayOfWeek.Sunday) to six (indicating DayOfWeek.Saturday).

You can also display the weekday name of a particular date by using the "D" format specifier or the "dddd" custom format specifier. For example:

Dim displayDate As New DateTimeOffset(#1/1/2008 1:18:00 PM#, _
outputBlock.Text &= String.Format("{0:D}", displayDate) & vbCrLf    ' Output: Tuesday, January 01, 2008                     
outputBlock.Text &= String.Format("{0:d} is a {0:dddd}.", _
                  displayDate)             ' Output: 1/1/2008 is a Tuesday. & vbCrLf

Note that the string returned by calling the ToString method of the DayOfWeek enumeration member that is returned by this property is not localized. To extract a string that contains the weekday name of the current culture or of a specific culture, call the ToString method with the "dddd" custom format specifier. For example, the following code displays the weekday name for a date using the fr-fr culture.

Dim thisDate As New DateTimeOffset(#6/1/2007 6:15:00 AM#, _
Dim weekdayName As String = thisDate.ToString("dddd", _
                            New CultureInfo("fr-fr"))
outputBlock.Text &= weekdayName & vbCrLf                        ' Displays vendredi     

The following example displays the weekday name of the first day of each month of the year 2008.

Dim startOfMonth As New DateTimeOffset(#1/1/2008#, _
Dim year As Integer = startOfMonth.Year
Do While startOfMonth.Year = year
   outputBlock.Text &= String.Format("{0:MMM d, yyyy} is a {1}.", _
                     startOfMonth, startOfMonth.DayOfWeek) & vbCrLf
   startOfMonth = startOfMonth.AddMonths(1)
' This example writes the following output:
'    Jan 1, 2008 is a Tuesday.
'    Feb 1, 2008 is a Friday.
'    Mar 1, 2008 is a Saturday.
'    Apr 1, 2008 is a Tuesday.
'    May 1, 2008 is a Thursday.
'    Jun 1, 2008 is a Sunday.
'    Jul 1, 2008 is a Tuesday.
'    Aug 1, 2008 is a Friday.
'    Sep 1, 2008 is a Monday.
'    Oct 1, 2008 is a Wednesday.
'    Nov 1, 2008 is a Saturday.
'    Dec 1, 2008 is a Monday.      


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions