1.取某月的最后一天
 1    //1.使用算出该月多少天,年+月+加上多少天即可,举例取今天最后一天
 2         private static void GetLastDateForMonth(DateTime dtStart,out DateTime dtEnd)
 3         {
 4             int dtYear, dtMonth;
 5             //dtStart = DateTime.Now;
 6             dtYear = dtStart.Year;
 7             dtMonth = dtStart.Month;
 8             int MonthCount = DateTime.DaysInMonth(dtYear, dtMonth);
 9             dtEnd = Convert.ToDateTime(dtYear.ToString() + "-" + dtMonth.ToString() + "-" + MonthCount);
10 
11         }
View Code
1       private static void GetLastDateForMonth(DateTime dtStart, out DateTime dtEnd)
2         {
3             int dtYear, dtMonth;
4             DateTime dtStart2= dtStart.AddMonths(1);
5             dtYear = dtStart2.Year;
6             dtMonth = dtStart2.Month;
7             dtEnd = Convert.ToDateTime(dtYear.ToString() + "-" + dtMonth.ToString() + "-" + "1").AddDays(-1);
8 
9         }
View Code

相关文章: