日期型变量的大小比较
Datetime rq1=Convent.ToDateTime("2005/01/01");
Datetime rq2=Convent.ToDateTime("2005/02/01");
if (DateTime.Compare(t1, t2) > 0) Console.WriteLine("t1 > t2");
if (DateTime.Compare(t1, t2) == 0) Console.WriteLine("t1 == t2");
if (DateTime.Compare(t1, t2) < 0) Console.WriteLine("t1 < t2");
我写的代码:
DateTime x = DateTime.Now;
Response.Write("<br>"+"x:"+x.ToString());
string y = "2009-3-20";
//string y = "3/28/2009";
DateTime j = Convert.ToDateTime(y);
Response.Write("<br>"+"j:"+j);
if (DateTime.Compare(x, j) > 0)
{
Response.Write("x>j");
}
else if(DateTime.Compare(x,j)<0)
{
Response.Write("x小于j");
}