在ASP中日期比较使用:DateDiff( "d", "2006-1-30", now )>0;在C#中使用:TimeSpan
代码如下:
using System;
using System.Collections;
public class DatediffClass
{
public static void Main()
{
DateTime dt1 = DateTime.Parse("2006-04-01");
DateTime dt2 = DateTime.Parse("2006-05-01");
TimeSpan ts = dt2.Subtract(dt1);
Console.WriteLine(ts.TotalDays);
Console.ReadLine();
}
}
如果是比较大小:DateTime.Compare(t1, t2) > 0