private void GetDates(ref System.DateTime stDate, ref System.DateTime endDate)
{
double offset = 0;
switch (System.DateTime.Today.DayOfWeek)
{
case DayOfWeek.Monday:
offset = 0;
break;
case DayOfWeek.Tuesday:
offset = -1;
break;
case DayOfWeek.Wednesday:
offset = -2;
break;
case DayOfWeek.Thursday:
offset = -3;
break;
case DayOfWeek.Friday:
offset = -4;
break;
case DayOfWeek.Saturday:
offset = -5;
break;
case DayOfWeek.Sunday:
offset = -6;
break;
}
endDate = System.DateTime.Today.AddDays(offset);
stDate = System.DateTime.Today.AddDays(-7 + offset);
}
courtesy : http://www.knowdotnet.com/articles/getpreviousmonday.html