DateTime dataA = DateTime.Parse(“2008-10-12 12:30:01″);
DateTime dataB = DateTime.Parse(“2008-10-12 12:30:02″);
int nA = dataA.CompareTo(dataB);
当nA == -1,dataA比dataB早
当nA == 0,dataA和dataB一样
当nA == 1,dataA比dataB晚
也可以直接比较:
DateTime dt1;
DateTime dt2;
bool b=dt1>dt2;