Small Question of Time(4RWilson, or anyone)

I'm using this:

StartTime, EndTime, CloseTime : TDateTime;

StartTime := NOW;
EndTime   := NOW;
CloseTime := NOW;

Label1.caption := FormatDateTime(HH:MM:SS, EndTime-StartTime);

This works great. But
Label2.caption := FormatDateTime(HH:MM:SS, CloseTime+EndTime);

adds the hours, minutes, and seconds together (as expected). I need a method to add the total time of Starttime with EndTime.
Ex: if Start time is 00:00:02 and end time is 00:00:10 then label2 should show 00:00:12 ( I need this to show corrctly also if the time goes into the minutes section, or the hour section.

Is there a way to do this?
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 can starttime be 00:00:02 ??? I mean 00:00:02 looks like a difference to something, it doesn't look like an absolute time... Hmmm... Perhaps I don't understand what you want?
Simple answer (in case you want to add actually _time_, not date):

ResultTime := TDateTime (Double (Time1) + Frac (Double (Time2)));

Where Time1 is original time and Time2 - time to add.

Actually, this is bad style, because add operation is not defined for time and date. Compiler does not respond an error because TDateTime is actually Double, meaning a number days since 30-DEC-1899 (afair) (fractional part means hours, minutes, secs, etc).

So you may play with them as you wish, only understand what the numbers mean.

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
JPersingerAuthor Commented:
Madshi -
I'm sorry for not being clear. The 00:00:02 is the total difference from EndTime (EndTime := NOW - which gets recorded when the second button is clicked) minus the StartTime (StartTime := NOW - which gets recorded when the first button gets clicked) value. So What I need is how to take the time (value) from the EndTime value (in this case 00:00:02) and add it to the value of the CloseTime value (which would get recorded when a third button gets clicked). So it should equal this: Mylabel.caption = CLoseTime + EndTime;
Hope this helps...In the meantime I'm going to try Sereda's answer and see what happens.

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Can you please give more details of this button clicking stuff? ;)
I think that the correct answer lies in correct question.
Correct time operations are:
DifTime = Time2 - Time1 (gives difference between dates in days, multiply this by 86400 to get it in secods)
Time2 = Time1 + DifTime

so i'll take a wild guess - you need something like
MyLabel.Caption := CloseTime + (EndTime - StartTime) ???

Otherwise i don't see much reason in the task.
JPersingerAuthor Commented:
so i'll take a wild guess - you need something like
MyLabel.Caption := CloseTime + (EndTime - StartTime) ???

Yes. Your right...The button click task is acting like a stop watch.

Press (or click)the stop watch and the race starts (StartTime). Click the stop watch again to record the end of lap one (EndTime). Click the stop watch again and you get the time it took to make it around the track on lap one and the total time of the race (CloseTime).

In real life:
I have an applcaition that will launch another application. I need to find out how long it takes to load this second application (endtime-starttime) so the user can begin using it. The user will click a few radio buttons and checkboxes on this second application and then close the applcation. I need to measure that time too (CloseTime+EndTime).  when complete I need it to tell me 1) How long it took to bring the app up, 2) configure it, and then 3) close it (closing it may take longer because of the data that is being saved out..does this help?
Okay, now it's clear.
The important part here is that you need to distinguish absolute time measurement (like NOW) and time difference (like EndTime-StartTime).
Here, you will have to make three absolute measurements:
StartTime := NOW;
EndTime := NOW;
App_Closed := NOW;

and then,
 EndTime - StartTime = number of days
 it took to start the application

 App_Closed - EndTime = number of days
 application worked

 App_Closed - StartTime = total
JPersingerAuthor Commented:
For this section, do I still need to divide the number of days by 86400 to get the seconds (since I really need the seconds, and hope the ap doesn't take days :)

App_Closed - EndTime = number of days
 application worked/86400 ?

you are almost right
you need to multyply :)
number_of_seconds := number_of_days * 86400;
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.