How to get week number from the Date in C#

Posted by Sheonarayan under C# category on | Points: 40 | Views : 8055
To get the week number from the Date in C#, use following function

public static int GetWeekNumber(DateTime thisDate)
return CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(thisDate, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Sunday);

This returns week number assuming first day of the week is Sunday.

Comments or Responses

Login to post response