Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between 2 dates in Delphi 5

I want to be able to find the difference in seconds between two TDateTime variables in Delphi 5. In the later versions of delphi there are helper functions SecondsBetween to do this. Is there a better way to do this other than rolling my own (Finding the difference of the two variables as a double then converting them to seconds)?

Thanks.

like image 283
d h Avatar asked Sep 13 '26 19:09

d h


2 Answers

Secs := Round(SecsPerMin * MinsPerHour * HoursPerDay * Abs(Time2 - Time1));
like image 146
NGLN Avatar answered Sep 16 '26 19:09

NGLN


Here goes another way of doing the same. Tested in Delphi 5

var
  Hour, Min, Sec, MSec: Word;
begin
  DecodeTime(datetime2-datetime1, Hour, Min, Sec, MSec);
end;
like image 40
Laura Lus Avatar answered Sep 16 '26 19:09

Laura Lus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!