Difference between two TDatetimes - formatted as string

I need a fuction which takes a StartTime (TDateTIme) and EndTime (TDateTIme) and returns the difference formatted as such 'Hours:Mins:Secs'

function GetDiffStr(End, Start: TDateTime): String
LVL 11
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

how about using this

 MilliSecondSpan(StartTime, EndTime) div 1000

to send to the TimeString function from yesterday


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Check out: http://www.bsdg.org/swag/DELPHI/0258.PAS.html

function GetDiffStr(End, Start: TDate): String
 DateSeparator:= '-';
 ShortDateFormat:= 'm/d/yyyy';
 result:= intToStr(daysBetween(aDay,bDay)));

Also you could check: http://beta.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20672746.html

If it helped please dont forget to accept the answer.
A TDateTime datatype is nothing but a wrapper around a double datatype.
this means that taking the difference between two TDateTime variables is just substract the one from the other

Diff := Date1 - Date2;

remember to have the 'DateUtils' in your uses clause

function GetDiffStr(End, Start: TDateTime): String
Diff: TDateTime;
Diff := Start - End;
result:= TimeToStr(Diff);

TimeToStr converts a TDateTime variable to a string, but ONLY the time part. If you want the exact difference with days too, use the DateTimeToStr(Diff) instead!

hope this helps

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

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.