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

日期比较失败,请教
2个都是DateTime型
DateTime tm1 ={7/19/2007};
DateTime tm2 ={7/19/2007};
判断if(tm1<=tm2) return;

这样比较,哪里不对啊?

------解决方案--------------------
DateTime tm1 =new DateTime(2007,1,19);
------解决方案--------------------
用DateTime.compare(t1,t2)
------解决方案--------------------

DateTime tm1 = Convert.ToDateTime("2007-7-9");
DateTime tm2 = Convert.ToDateTime("2007-7-19");
------解决方案--------------------
DateTime tm1 = Convert.ToDateTime("2007/7/9"); 
DateTime tm2 = Convert.ToDateTime("2007/7/19");
if(tm1>tm2)
{

}