+ Reply to Thread
Results 1 to 6 of 6

Calculate duration (h:mm) between two dates/times

  1. #1
    Registered User
    Join Date
    11-20-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    4

    Calculate duration (h:mm) between two dates/times

    Dear Sir/Mdm,

    I'm trying to calculate hours and minutes (h:mm) between two dates/times over more than 24hrs.


    I have for example:-


    Start Date/Time within the same cell - A2 is 21/07/10 08:47:00
    End Date & Time within the same cell - B2 is 23/07/10 05:12:00

    Attached a sample of my file.
    What formula can I use?
    Attached Files Attached Files

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,721

    Re: Calculate duration (h:mm) between two dates/times

    You can use a simple subtraction, e.g. in C2 copied down

    =A2-B2

    Custom format C2 as [h]:mm
    Audere est facere

  3. #3
    Registered User
    Join Date
    11-20-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Calculate duration (h:mm) between two dates/times

    Quote Originally Posted by daddylonglegs View Post
    You can use a simple subtraction, e.g. in C2 copied down

    =A2-B2

    Custom format C2 as [h]:mm

    I believe you meant =B2-A2? The results I received are #VALUE! There are no numbers (h:mm) displayed.

  4. #4
    Registered User
    Join Date
    11-03-2011
    Location
    Shelton, CT
    MS-Off Ver
    Excel 2010
    Posts
    67

    Re: Calculate duration (h:mm) between two dates/times

    You need to first convert the data in Cols A and B and then do the math. I have attached what I think is a simple fix without code.

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,721

    Re: Calculate duration (h:mm) between two dates/times

    Quote Originally Posted by Jetfree View Post
    I believe you meant =B2-A2? The results I received are #VALUE! There are no numbers (h:mm) displayed.
    Sorry, yes, I meant B2-A2

    That works for me, my regional settings recognise dd/mm/yyyy dates rather than mm/dd/yyyy. What is your default date format? If it isn't dd/mm/yyyy then optomyst's suggestion should work for you......I think you can use a shorter version though, try

    =REPLACE(MID(B2,4,14),4,0,LEFT(B2,3))-REPLACE(MID(A2,4,14),4,0,LEFT(A2,3))

    format C2 as [h]:mm
    Last edited by daddylonglegs; 11-20-2011 at 01:36 PM.

  6. #6
    Registered User
    Join Date
    11-20-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    4

    Smile Re: Calculate duration (h:mm) between two dates/times

    Quote Originally Posted by daddylonglegs View Post
    Sorry, yes, I meant B2-A2

    That works for me, my regional settings recognise dd/mm/yyyy dates rather than mm/dd/yyyy. What is your default date format? If it isn't dd/mm/yyyy then optomyst's suggestion should work for you......I think you can use a shorter version though, try

    =REPLACE(MID(B2,4,14),4,0,LEFT(B2,3))-REPLACE(MID(A2,4,14),4,0,LEFT(A2,3))

    format C2 as [h]:mm


    Great! It works. Thank you so much.
    Is it a problem calculating duration if the file I received has dates in the mm/dd/yy format?

    By the way, how do I sort the column of data from earliest to latest with such date/time format (21/07/10 08:47:00)?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1