For statistics, you must first obtain the specified date to obtain the first day of the week where the date is located, so as to determine the day to which the week is located.
First read the following code to obtain the date of the current day.
DateTime. Today
If you specify a date instead of the current day, convert it to a date.
DateTime dt = Convert. ToDateTime ();
If you set the specified date to an irregular Date Format String, use DateTime. ParseExact to convert the http://www.cnblogs.com/insus/p/3231007.html.
DateTime has a function that returns the day of the week, such
Dt. DayOfWeek
It will return Sunday, Monday, Tuesday ......
If we convert it into an integer, for example:
() Dt. DayOfWeek
It returns 0, 1, 2 ......
In this case, we can use the. AddDays () method to calculate the start date of the week where the specified date is located: