Is that not about the same question you just closed ?
if you want to have the nb of days, hours, min you can use
procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);
in SysUtils
Main Topics
Browse All Topicswe need an function to returno number of hours (abouve 24 hours) using TDateTime
Sample:
dt_1: TDateTime;
dt_2: TDateTime;
dt_1 := StrToDateTime('12/28/2009 00:00');
dt_2 := StrToDateTime('12/30/2009 13:15');
dt_2 - dt_1 = return 3 days and 1 hours and 15 minutes
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Ah, actually by looking again at this thread, I see that what you need is not exactly DecodeDate but
DecodeDateTime(const AValue: TDateTime; out AYear: Word; out AMonth: Word; out ADay: Word; out AHour: Word; out AMinute: Word; out ASecond: Word; out AMilliSecond: Word);
Var
Year, Month, Day: Word;
Hour, Min, Sec, MilSec: Word;
begin
DecodeDateTime( dt_2 - dt_1, Year, Month, Day, Hour, Min, Sec, MilSec );
end;
Or DecodeTime + nb of full days not decoded (=8 if 1week+1day) :
Var
Days: Word;
Hour, Min, Sec, MilSec: Word;
begin
DecodeDateTime( dt_2 - dt_1, Hour, Min, Sec, MilSec );
Days:=Trunc( dt_2-dt_1);
end;
Now you have about all possible solutions, choose the best suited for your needs
A TDateTime is the number of days since some date (can't remember what date but that is not important)
So i you have two TDateTime d1 and d2 the number of days between them is Trunc(d2-d1)
what is left (ie frac(d2-d1) is the number hours:min...
The fractional part represent the time,
So if f = frac(d2-d1) you have:
Hours = trunc(f*24)
Minutes = trunc(f*24*60)-Hours*60
Seconds = trunc(f*24*60)-Hours*60-Mi
I have assumed that d2 is larger than d1, if not you can swap them and then use the above.
By the way if you just want to display the difference you can also use IntToStr(trunc(d2-d1) + " days " + TimeToString(d2-d1)
(I think it was called TimeToString but something like that) again d2 should be larger than d1.
Business Accounts
Answer for Membership
by: rfwoolfPosted on 2009-11-03 at 09:30:31ID: 25731329
Add Dateutils unit to your uses list
Use Daysbetween,
Hours between,
Minutesbetween functions
or look at the Dateutils methods list in the help file for a full list of date and time handling functions