For any given date, how would you find the week ending date of the last completed week, if your week runs from Sunday to Saturday?
DateTime StartOfWeek = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek);
DateTime EndOfLastWeek = StartOfWeek.AddDays(-1);
DateTime givenDate; // = ...
int daysToOffset = ((int)givenDate.DayOfWeek + 1) * -1;
DateTime lastDayOfLastCompletedWeek = givenDate.AddDays(daysToOffset);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With