Asp.Net: Method to get week number (getweekofyear)

by Pieter Brinkman 21. February 2009 09:41

This method return the integer weeknumber of a specific date. 

public static int GetWeekNumber(DateTime date)
{
 // Gets the Calendar instance associated with a CultureInfo.
 CultureInfo myCI = new CultureInfo("nl-NL");
 Calendar myCal = myCI.Calendar;

 // Gets the DTFI properties required by GetWeekOfYear.
 CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule;
 DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;

 return myCal.GetWeekOfYear(date, myCWR, myFirstDOW);
}

More info:
http://msdn.microsoft.com/en-us/library/system.globalization.calendar.getweekofyear.aspx

 

Tags: , ,

ASP.Net

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About Me

My name is Pieter Brinkman I am Solution Architect for Sitecore in The Netherlands. My interests are mainly ASP.NET, MSSQL and Content Management Systems.

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

RecentComments

Comment RSS

Most comments