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