Datetime.compare (T1,T2) compares two date sizes

Source: Internet
Author: User

Datetime.compare (T1,T2) comparison two date size, the front of the small, row in the back of the 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 is equal to zero: T1 equals T2.
The return value is greater than 0: T1 is greater than T2.

Such as:
Using System; Using System.Collections.Generic; Using System.Linq; Using System.Text; Namespace ConsoleApplication1 {class Program {static void Main (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"); } } }

Run Result:

T1 < T2
Please press any key to continue ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.