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);
No one seems to have answered this correctly yet. I'll paste my solution here in case anyone needs it. The following code works regardless if first day of the week is a monday or a sunday or something else.
if you want saturday or sunday or any day of week but not exceeding current week(Sat-Sun) I got you covered with this piece of code.
Using Fluent DateTime:
Thanks for the examples. I needed to always use the "CurrentCulture" first day of the week and for an array I needed to know the exact Daynumber.. so here are my first extensions: