MinutesApart Function
Returns the number of whole minutes apart the two times are (date portion ignored) and DT1 is assumed to be before DT2.

Unit
QESBPCSDateTime

Declaration
Function MinutesApart(const DT1, DT2: TDateTime): Word;

Parameters
DT1 First Time, Date portion ignores - assumed to be the earlier time.
DT2 Second Time, Date portion ignores - assumed to be the later time.

Category
Date/Time Arithmetic Routines

Implementation

function MinutesApart (const DT1, DT2: TDateTime): Word;
var
     Hr1, Min1, Sec1, MSec1: Word;
     Hr2, Min2, Sec2, MSec2: Word;
begin
     ESBDecodeTime (DT1, Hr1, Min1, Sec1, MSec1);
     ESBDecodeTime (DT2, Hr2, Min2, Sec2, MSec2);
     if Min2 < Min1 then
     begin
          Min2 := Min2 + 60;
          if Hr2 > 0 then
               Dec (Hr2)
          else
               Hr2 := 23;
     end;
     if Hr1 > Hr2 then
          Hr2 := Hr2 + 24;
     Result := (Hr2 - Hr1) * 60 + (Min2 - Min1);
End;


HTML generated by Time2HELP
http://www.time2help.com