.NET Script to Find Work Week Start and End


If you need to find the Monday of a given week or a Friday of a given week, this is the solution for you:

private DateTime WorkWeekStart(DateTime date)
{
    DateTime result = date.AddDays(-((int)date.DayOfWeek)).AddDays(1); //Sunday + 1 = Monday
    return result;
}
private DateTime WorkWeekStop(DateTime date)
{
   DateTime result = date.AddDays(6 - ((int)date.DayOfWeek)).AddDays(-1); //Saturday - 1 = Friday
   return result;
}