Get the week number of a given date

Get the week number of a given date
The C# method uses the DateTime object to get the week number of a given date. The number returned is dependent on the culture of the target machine.
1. public static int GetWeekNumber(DateTime dtPassed)
2. {
3.         CultureInfo ciCurr = CultureInfo.CurrentCulture;
4.         int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed,  CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
5.         return weekNum;
6. }

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top