Comparedatetime, comparedate, comparetime, samedatetime, samedate, and sametime-comparison Time Functions

Source: Internet
Author: User
Comparedatetime, comparedate, and comparetime return-1, 0, and 1;
The former = the latter: returns 0;
The former> the latter: return 1;
Former

True and false are returned for samedatetime, samedate, and Sametime.

Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs; Type tform1 = Class (tform) Procedure formcreate (Sender: tobject); end; vaR form1: tform1; implementation {$ R *. DFM} uses dateutils; Procedure tform1.formcreate (Sender: tobject); var T1, T2: tdatetime; R1, R2, R3: integer; B1, B2, B3: Boolean; begin {date consistency and Time Inconsistency} T1: = strtodatetime ('2017-5-20 '); t2: = strtodatetime ('2017-5-20 '); r1: = comparedatetime (T1, T2); // 1 R2: = comparedate (T1, T2); // 0 R3: = comparetime (T1, T2 ); // 1 B1: = samedatetime (T1, T2); // false B2: = samedate (T1, T2); // true B3: = Sametime (T1, T2 ); // false {date and time are consistent} T1: = strtodatetime ('2017-5-20 '); t2: = strtodatetime ('2017-5-21 '); r1: = comparedatetime (T1, T2); //-1 R2: = comparedate (T1, T2 ); //-1 R3: = comparetime (T1, T2); // 0 B1: = samedatetime (T1, T2); // false B2: = samedate (T1, T2 ); // false B3: = Sametime (T1, T2); // true {date and time are inconsistent} T1: = strtodatetime ('2017-5-19 '); t2: = strtodatetime ('2017-5-20 '); r1: = comparedatetime (T1, T2); //-1 R2: = comparedate (T1, T2 ); //-1 R3: = comparetime (T1, T2); // 1 B1: = samedatetime (T1, T2); // false B2: = samedate (T1, T2 ); // false B3: = Sametime (T1, T2); // falseend; end.
Dateutils-Function

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.