Datetime.compare (T1,T2) compares two date size, row front small, row in the back big, for example: 2011-2-1 is less than 2012-3-2
The return value is less than 0: T1 is less than T2.
The return value equals zero: T1 equals T2.
The return value is greater than 0: T1 is greater than T2.
usingSystem; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; namespaceConsoleApplication1 {classProgram {Static voidMain (string[] args) {DateTime T1= DateTime.Parse ("2011-2-2"); DateTime T2= DateTime.Parse ("2011-3-1"); 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"); } } }
Operation Result:
T1 < T2
Please press any key to continue ...
ASP. NET time comparison, often used to operate at a certain time