This week, 1st, returns the result format: 2014-5-5 0:00:00
public static DateTime Getmondaydate ()
{
DateTime Dt=datetime.now;
int today= (int) dt. DayOfWeek;
if (dt. Dayofweek.tostring ()! = "Sunday")//You can also use the today!=0
{
Return dt. AddDays (1-today). Date;
}
Else
{
Return dt. AddDays ( -6-today). date;//If today is Sunday, get the week 1st period is the date of the next Monday, so subtract 7 days
}
}
This Sunday day
public static DateTime Getsundaydate ()
{
DateTime Dt=datetime.now;
int today= (int) dt. DayOfWeek;
if (dt. Dayofweek.tostring ()! = "Sunday")//You can also use the today!=0
{
Return dt. AddDays (7-today). Date;
}
Else
{
Return dt. AddDays (-today). date;//If today is Sunday, get the Sunday date is the date of next Sunday, so subtract 7 days
}
}
Last 1st
public static DateTime Getlastmondaydate ()
{
DateTime Dt=datetime.now;
int today= (int) dt. DayOfWeek;
if (dt. Dayofweek.tostring ()! = "Sunday")//You can also use the today!=0
{
Return dt. AddDays (-today-6). Date;
}
Else
{
Return dt. AddDays (-TODAY-13). date;//If today is Sunday, get the date of last Monday is the date of this week Monday, so subtract 7 days
}
}
Last week Giges period
public static DateTime Getlastsundaydate ()
{
DateTime Dt=datetime.now;
int today= (int) dt. DayOfWeek;
if (dt. Dayofweek.tostring ()! = "Sunday")//You can also use the today!=0
{
Return dt. AddDays (-today). Date;
}
Else
{
Return dt. AddDays (-today-7). date;//If today is Sunday, get the date of last Sunday is the date of this week Sunday, so subtract 7 days
}
}
Next week 1st
public static DateTime Getnextmondaydate ()
{
DateTime Dt=datetime.now;
int today= (int) dt. DayOfWeek;
if (dt. Dayofweek.tostring ()! = "Sunday")//You can also use the today!=0
{
Return dt. AddDays (-today+8). Date;
}
Else
{
Return dt. AddDays (-today+1). date;//If today is Sunday, get the next week 1st period is next Monday date, so subtract 7 days
}
}
Next Sunday Day
public static DateTime Getnextsundaydate ()
{
DateTime Dt=datetime.now;
int today= (int) dt. DayOfWeek;
if (dt. Dayofweek.tostring ()! = "Sunday")//You can also use the today!=0
{
Return dt. AddDays (14-today). Date;
}
Else
{
Return dt. AddDays (7-today). date;//If today is Sunday, get the next Sunday day is next Sunday date, so subtract 7 days
}
}