What is the best way to calculate the previous week\'s start and end date in C#? I.e. today 18 March would result in 9 March (Monday last week) and 15 March (Sunday last we
DayOfWeek weekStart = DayOfWeek.Monday; // or Sunday, or whenever
DateTime startingDate = DateTime.Today;
while(startingDate.DayOfWeek != weekStart)
startingDate = startingDate.AddDays(-1);
DateTime previousWeekStart = startingDate.AddDays(-7);
DateTime previousWeekEnd = startingDate.AddDays(-1);
Read: Backtrack one day at a time until we're at the start of this week, and then subtract seven to get to the start of last week.