[Overview][Constants][Procedures and functions] Reference for unit 'dateutils' (#rtl)

SameDateTime

Check whether two TDateTimevalues have the same date and time parts.

Declaration

Source position: dateutil.inc line 354

function SameDateTime(

  const A: TDateTime;

  const B: TDateTime

):Boolean;

Arguments

A

  

First DateTime value

B

  

Second DateTime value

Function result

Trueif Aand Bhave the same date and time parts, Falseif not.

Description

SameDateTimecompares the date/time parts of two timestamps Aand Band returns Trueif they are equal, Falseif they are not.

The function simply checks whether CompareDateTimereturns zero.

See also

CompareDateTime

  

Compare 2 dates, taking into account the time of day

CompareDate

  

Compare 2 dates, disregarding the time of day

CompareTime

  

Compares two times of the day, disregarding the date part.

SameDate

  

Check whether two TDateTimevalues have the same date part.

SameTime

  

Check whether two TDateTimevalues have the same time part.

Example

Program Example101;

{ This program demonstrates the SameDateTime function }

Uses SysUtils,DateUtils;

Const
  Fmt = 'dddd dd mmmm yyyy hh:nn:ss.zzz';

Procedure Test(D1,D2 : TDateTime);

begin
  Write(FormatDateTime(Fmt,D1),' is the same datetime as ');
  Writeln(FormatDateTime(Fmt,D2),' : ',SameDateTime(D1,D2));
end;

Var
  D,N : TDateTime;

Begin
  D:=Today;
  N:=Now;
  Test(D,D);
  Test(N,N);
  Test(N+1,N);
  Test(N-1,N);
  Test(N+OneSecond,N);
  Test(N-OneSecond,N);
End.