Getting start date of the first week of the year

Posted by Sheonarayan under C# category on | Points: 40 | Views : 442
Following function can be used to get the start date of the first week of the year.

public static DateTime GetStartDaysOfTheYear(int year)
DateTime startOfTheYear = new DateTime(year, 1, 1);
return startOfTheYear.AddDays(-(int)startOfTheYear.DayOfWeek);

Call it like below


Here the parameter of this function is year.

Comments or Responses

Login to post response