日期:2014-05-18  浏览次数:20423 次

判断时间一个月内
如何用脚本或者net判断一个时间范围内不能超出一年?
比如开始时间是2011-10-1
如果结束时间是2011-11-2号,就不让它查询,因为超过了一个月。 


------解决方案--------------------
C# code

  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");