Getting end date of the current week

Posted by Sheonarayan under C# category on | Points: 40 | Views : 422
To get the end date of the current week, use below function.
public static DateTime EndDateOfCurrentWeek(DateTime input, DayOfWeek dayOfWeek)
int delta = dayOfWeek - input.DayOfWeek;
return input.AddDays(delta);

Call it like this
Response.Write(EndDateOfCurrentWeek(DateTime.Now, DayOfWeek.Saturday));

Here the first parameter is current date and second parameter is last day of the week.

Comments or Responses

Login to post response