Get the number of days between 2 TDateTime structures

Has anybody some code handy to get the number of days that had passed between two TDateTime structures?
jonnyfiveAsked:
Who is Participating?
 
MadshiConnect With a Mentor Commented:
Very simple. Just look at the difference.

dt2-dt1 = 2.5    =>  two and a half days past by...

Regards, Madshi.
0
 
heathprovostCommented:
Sure, just subtract 1 from the other.  Like This

function ElapsedDays(D1, D2: TDateTime): integer;
begin
  Result := Round(abs(D1 - D2));
end;
0
 
heathprovostCommented:
Oops, Sorry Madshi - Posted at same time :)

Heath
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
heathprovostCommented:
BTW - I should have put Trunc instead of Round. Wasnt thinking

Heath
0
 
jonnyfiveAuthor Commented:
Besides that I'm wondering if you guys ever sleep, I'm very impressed with the quick and excellent solutions I got from you. Thanks a lot and points well earned :-))

0
 
MadshiCommented:
:-)

Am sitting at work right now. So I check my eMails and EE every hour. It's good that my boss works two streets from here...  :-)

Regards, Madshi.
0
 
MadshiCommented:
Hi Heath, hmmm. If I would have written a little function (like you did), you would have probably been faster than I. So I'm sorry for taking the points away...    :-)
0
All Courses

From novice to tech pro — start learning today.