#region old based on year, month, week, calculate specific day
<summary>
Old based on year, month, week, calculate specific day
</summary>
public Object Showweekdate (int year, int month)
{
list<object> lists = new list<object> ();
String str = "";
The first day of the current month
DateTime weekstart = new DateTime (year, month, 1);
The last day of the month
DateTime monend = weekstart.addmonths (1). AddDays (-1);
int i = 1;
The first day of the current month is the days of the week
int dayOfWeek = Convert.ToInt32 (weekStart.DayOfWeek.ToString ("D"));
End date of the first week of the month
DateTime WeekEnd = DayOfWeek = = 0? WeekStart:weekStart.AddDays (7-dayofweek);
str + = "First" + i + "Week start Date:" + weekstart.toshortdatestring () + "End Date:" + weekend.toshortdatestring () + "\ n";
var dateSpanWeek1 = new {StartDate = Weekstart.toshortdatestring (), EndDate = Weekend.toshortdatestring ()};
Lists. ADD (DATESPANWEEK1);
When the date is less than or equal to the last day of the month
while (Weekend.adddays (1) <= monend)
{
i++;
Start time of the week
Weekstart = weekend.adddays (1);
End time of the week
WeekEnd = weekend.adddays (7) > Monend? MonEnd:weekEnd.AddDays (7);
str + = "First" + i + "Week start Date:" + weekstart.toshortdatestring () + "End Date:" + weekend.toshortdatestring () + "\ n";
var dateSpanWeek2 = new {StartDate = Weekstart.toshortdatestring (), EndDate = Weekend.toshortdatestring ()};
Lists. ADD (DATESPANWEEK2);
}
STR + + year + "years" + month + "Monthly Total" + i + "week \ n";
return lists;
}
#endregion old based on year, month, week, calculate specific day
Based on year, month, week, calculation specific one day (Monday)