Solved

Get the number of days between 2 TDateTime structures

Posted on 1999-01-27
7
160 Views
Last Modified: 2010-04-06
Has anybody some code handy to get the number of days that had passed between two TDateTime structures?
0
Comment
Question by:jonnyfive
  • 3
  • 3
7 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 50 total points
ID: 1363542
Very simple. Just look at the difference.

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

Regards, Madshi.
0
 
LVL 5

Expert Comment

by:heathprovost
ID: 1363543
Sure, just subtract 1 from the other.  Like This

function ElapsedDays(D1, D2: TDateTime): integer;
begin
  Result := Round(abs(D1 - D2));
end;
0
 
LVL 5

Expert Comment

by:heathprovost
ID: 1363544
Oops, Sorry Madshi - Posted at same time :)

Heath
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:heathprovost
ID: 1363545
BTW - I should have put Trunc instead of Round. Wasnt thinking

Heath
0
 

Author Comment

by:jonnyfive
ID: 1363546
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
 
LVL 20

Expert Comment

by:Madshi
ID: 1363547
:-)

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
 
LVL 20

Expert Comment

by:Madshi
ID: 1363548
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now