I have this line of code that works perfectly for monday but doesn't quite work for sunday
DateTime startatmonday = DateTime.Now.AddDays(DayOfWeek.Monday - DateTime.Now.DayOfWeek); DateTime startatsunday = DateTime.Now.AddDays(DayOfWeek.Sunday - DateTime.Now.DayOfWeek);
As seen in the image Below Sunday Image
I require this code to work as i am using a calendar selection and the code behind is to Calculate the first day of the week (Monday) and the last day of the week (Sunday)
DateTime startatmonday = Calendar1.SelectedDate.AddDays(DayOfWeek.Monday - Calendar1.SelectedDate.DayOfWeek); DateTime startatsunday = Calendar1.SelectedDate.AddDays(Calendar1.SelectedDate.DayOfWeek - DayOfWeek.Sunday );
Does anyone know any alternative solutions or a fix to the sunday problem?
https://stackoverflow.com/questions/65894873/finding-the-date-of-monday-and-sunday-of-calendar-selecteddate-asp-net January 26, 2021 at 09:51AM
没有评论:
发表评论