Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

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?
0
jonnyfive
Asked:
jonnyfive
  • 3
  • 3
1 Solution
 
MadshiCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now