The difference between two times

Posted on 2005-04-13
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
Question by:wildzero
    LVL 11

    Expert Comment

    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

    LVL 11

    Accepted Solution

    extended version

    assuming times are in edit1 and edit 2

      if StrToTime(edit2.text)<StrToTime(edit1.text) then

    LVL 10

    Author Comment

    Perfect thanks alot!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    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…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    737 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

    20 Experts available now in Live!

    Get 1:1 Help Now