1. Take the last day of a month
1. Take the last day of a month
Method 1: calculate the number of days and years of the month. + Month + The number of days that can be added. For example, the last day of the month is used.
Private Void Getlastdateformonth (datetime dtstart, Out Datetime dtend)
{
Int Dtyear, dtmonth;
Dtstart = Datetime. now;
Dtyear = Dtstart. Year;
Dtmonth = Dtstart. month;
Int Monthcount = Datetime. daysinmonth (dtyear, dtmonth );
Dtend = Convert. todatetime (dtyear. tostring () + " - " + Dtmonth. tostring () + " - " + Monthcount );
}
Method 2: retrieve the first day of next month minus one day is the last day.
Private Void Getlastdateformonth (datetime dtstart, Out Datetime dtend)
{
Int Dtyear, dtmonth;
Dtstart = Datetime. Now. addmonths ( 1 );
Dtyear = Dtstart. Year;
Dtmonth = Dtstart. month;
Dtend = Convert. todatetime (dtyear. tostring () + " - " + Dtmonth. tostring () + " - " + " 1 " ). Adddays ( - 1 );
}
Method 1: calculate the number of days and years of the month.+Month+The number of days that can be added. For example, the last day of the month is used.
Method 2: retrieve the first day of next month minus one day is the last day.