Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • 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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

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