DayOfYear Property

DateTime::DayOfYear Property

 

Gets the day of the year represented by this instance.

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

public:
property int DayOfYear {
	int get();
}

Property Value

Type: System::Int32

The day of the year, expressed as a value between 1 and 366.

TheDayOfYear property takes leap years into account when it calculates the day of the year. The property value always reflects the day of the year in the Gregorian calendar, regardless of the current thread culture's current calendar. To retrieve the day of the year in a different calendar, call the Calendar::GetDayOfYear method of that calendar.

The following example displays the day of the year of December 31 for the years 2010-2020 in the Gregorian calendar. Note that the example shows that December 31 is the 366th day of the year in leap years.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft