按月算

DateTime dt1= DateTime.Parse("2011-11-2");
   DateTime dt2
= DateTime.Parse("2011-10-1");
   
if(dt1.AddMonths(-1)>dt2)
     Console.WriteLine(
"more than one month");
   
else Console.WriteLine("less than one month");

string MonthStart = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + "1" + " " + "00:00:00";

string MonthEnd = Convert.ToString(Convert.ToDateTime(MonthStart).AddMonths(1).AddSeconds(-1));

posted @ 2012-05-31 20:13  踏浪帅  阅读(183)  评论(0编辑  收藏  举报