Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DateTime::DayOfWeek Property

Gets the day of the week represented by this instance.

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

property DayOfWeek DayOfWeek {
	DayOfWeek get ();

Property Value

Type: System::DayOfWeek
An enumerated constant that indicates the day of the week of this DateTime value.

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 (which indicates DayOfWeek::Sunday) to six (which indicates DayOfWeek::Saturday).

The DayOfWeek property returns an enumerated constant; it does not reflect a system's regional and language settings. To retrieve a string representing a localized weekday name for a particular date, call one of the overloads of the ToString method that includes a format parameter and pass it either the ddd or dddd custom format strings. For details, see How to: Extract the Day of the Week from a Specific Date.

The following example demonstrates the DayOfWeek property and the System::DayOfWeek enumeration.

// This example demonstrates the DateTime.DayOfWeek property 
using namespace System;
int main()

   // Assume the current culture is en-US. 
   // Create a DateTime for the first of May, 2003.
   DateTime dt = DateTime(2003,5,1);
   Console::WriteLine(  "Is Thursday the day of the week for {0:d}?: {1}", dt, dt.DayOfWeek == DayOfWeek::Thursday );
   Console::WriteLine(  "The day of the week for {0:d} is {1}.", dt, dt.DayOfWeek );

This example produces the following results:

Is Thursday the day of the week for 5/1/2003?: True
The day of the week for 5/1/2003 is Thursday.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
© 2015 Microsoft