Click here to Skip to main content
15,893,337 members
Articles / Programming Languages / C#
Tip/Trick

Get week from Specific date

Rate me:
Please Sign up or sign in to vote.
4.67/5 (3 votes)
22 Apr 2010CPOL 10.1K   1   2
DateTime date = DateTime.Now;System.Globalization.CultureInfo cult_info = System.Globalization.CultureInfo.CreateSpecificCulture("no");System.Globalization.Calendar cal = cult_info.Calendar;int weekNo = cal.GetWeekOfYear(date, cult_info.DateTimeFormat.CalendarWeekRule,...
DateTime date = DateTime.Now;

System.Globalization.CultureInfo cult_info = System.Globalization.CultureInfo.CreateSpecificCulture("no");

System.Globalization.Calendar cal = cult_info.Calendar;

int weekNo = cal.GetWeekOfYear(date, cult_info.DateTimeFormat.CalendarWeekRule, cult_info.DateTimeFormat.FirstDayOfWeek);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions

 
GeneralReason for my vote of 4 Good tip Pin
subodhkant2-Feb-11 2:50
subodhkant2-Feb-11 2:50 
GeneralReason for my vote of 2 I live in sweden where week numbers ... Pin
Per Söderlund7-Jul-10 8:56
Per Söderlund7-Jul-10 8:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.