[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

The difference between two times

Posted on 2005-04-13
3
Medium Priority
?
263 Views
Last Modified: 2010-04-04
Hi there,

I have two times in the format like 4:10:05 PM and 4:15:09 PM
How can I find the difference between two times like that? Or could be 4:10:05 PM and 1:05:07 AM - how can I find the difference?

Many thanks
0
Comment
Question by:wildzero
  • 2
3 Comments
 
LVL 11

Expert Comment

by:pcsentinel
ID: 13771753
label1.caption:=formatdatetime('hh:mm:ss',StrToTime('4:10:05 PM ')-StrToTime('4:10:05 PM'));

but you could extend this is the second time might be earleir but on the next day

regards
0
 
LVL 11

Accepted Solution

by:
pcsentinel earned 500 total points
ID: 13771766
extended version

assuming times are in edit1 and edit 2


  if StrToTime(edit2.text)<StrToTime(edit1.text) then
      label1.caption:=formatdatetime('hh:mm:ss',StrToTime(edit2.text)+1-StrToTime(edit1.text))
   else
      label1.caption:=formatdatetime('hh:mm:ss',StrToTime(edit2.text)-StrToTime(edit1.text));

regards
0
 
LVL 10

Author Comment

by:wildzero
ID: 13771910
Perfect thanks alot!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

865 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