Getting start date of the first week of the year

Sheonarayan
Posted by Sheonarayan under C# category on | Points: 40 | Views : 1125
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

Response.Write(GetStartDaysOfTheYear(2014).ToString());


Here the parameter of this function is year.

Comments or Responses

Login to post response