How do I find the start of the week (both Sunday and Monday) knowing just the current time in C#?
Something like:
DateTime.Now.StartWeek(Monday);
How do I find the start of the week (both Sunday and Monday) knowing just the current time in C#?
Something like:
DateTime.Now.StartWeek(Monday);
Let's combine the culture-safe answer and the extension method answer:
A little more verbose and culture-aware:
Quickest way I can come up with is:
If you would like any other day of the week to be your start date all you need to do is add the DayOfWeek value to the end
Ugly but it at least gives the right dates back
With start of week set by system:
Without:
Same for end of week (in style of @Compile This's answer):