How to determine the time 'amount' between two times?

Posted on 2008-11-08
Last Modified: 2012-05-05

I have a table which contains time management data. We have:

R = Registration
A = Arrival
D = Departure

Time information for A and D can be in the table multiple times for one of our employees. What I would like to do is show the amount of time between the R and the last D of the day.

So R = 08:00 and the last D = 18:30 so the time amount would be 10 hours and 30 minutes.

Is there any way to do this in MySQL?


Question by:kenuk110
    LVL 8

    Accepted Solution

    You may use the timediff() function:

    SELECT MAX(TIMEDIFF(D, R)) FROM thetable WHERE condition

    Author Closing Comment

    Worked perfectly.

    Thank you.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    730 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

    15 Experts available now in Live!

    Get 1:1 Help Now