Click or drag to resize

DateTimeExtensionsWeekOfYear Method

Returns the week number of this DateTime.

Namespace: InnerDrive.Core
Assembly: InnerDrive.Core (in InnerDrive.Core.dll) Version: 5.0.8475.0
Syntax
C#
public static int WeekOfYear(
	this DateTime dateTime
)

Parameters

dateTime  DateTime
This DateTime.

Return Value

Int32
The number of weeks since the week containing January 1st.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DateTime. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
Week number 1 in any given year is the week containing January 1st. Weeks begin on Monday by default. So Week 1 of 2005 actually began on 27 December 2004.
Example
C#
var testDate = new DateTime(2010, 11, 17);
? testDate.WeekOfYear();

// Result: 47
See Also