+ Reply to Thread
Results 1 to 6 of 6

Formula to calculate duration

  1. #1
    Registered User
    Join Date
    03-15-2013
    Location
    Baltimore
    MS-Off Ver
    Excel 2010
    Posts
    33

    Formula to calculate duration

    Hi,

    I would to calculate the duration but the data I have has a different format than what I'm used to. Please see attached.

    Thank you in advance for your time and assistance.
    Jocelyn
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Slough
    MS-Off Ver
    Excel 2007
    Posts
    469

    Re: Formula to calculate duration

    I think this is what you want? I had to change a few formats for it.

    Change the times in columns C and D to include :

    Then the formula is - =SUM(RIGHT(D2,4)-RIGHT(C2,4))

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Formula to calculate duration

    Im sure there is a simpler way to do this, but try...
    =(DATEVALUE(LEFT(D2,10))+TIMEVALUE(MID(D2,12,2)&":"&RIGHT(D2,4)))-(DATEVALUE(LEFT(C2,10))+TIMEVALUE(MID(C2,12,2)&":"&RIGHT(C2,4)))
    copied down

    edit: Correction...
    =(DATEVALUE(LEFT(D2,10))+TIMEVALUE(MID(D2,12,2)&":"&RIGHT(D2,2)))-(DATEVALUE(LEFT(C2,10))+TIMEVALUE(MID(C2,12,2)&":"&RIGHT(C2,2)))
    Last edited by FDibbins; 09-15-2016 at 09:30 AM.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Formula to calculate duration

    If the dates will always be teh same, here is a shorter version...
    =TIMEVALUE(MID(D2,12,2)&":"&RIGHT(D2,2))-TIMEVALUE(MID(C2,12,2)&":"&RIGHT(C2,2))

    Note that in your last row, you have Pre-op before In fac?

    @ Danny, your formula doesnt always work, check the 2nd row. Duration is 29 minutes, but your formula shows 69?

  5. #5
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Slough
    MS-Off Ver
    Excel 2007
    Posts
    469

    Re: Formula to calculate duration

    It works fine when I test it. All you need to do is format it to custom ([h]:mm or [m]) or time and it shows as 00:29. If dates are going to be different then obviously it won't work. I worked on the assumption it would always be the same date.

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,175

    Re: Formula to calculate duration

    Another way ...

    =TEXT(RIGHT(D2,4),"00\:00")-TEXT(RIGHT(C2,4),"00\:00")

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] calculate duration
    By azbi in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-31-2016, 11:45 PM
  2. Calculate a limited duration
    By Johnny Image in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-25-2013, 10:47 AM
  3. [SOLVED] Formula: To calculate duration between two times, if duration is over 6hours subtract 30mi
    By MattBarnes7 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-11-2013, 03:22 PM
  4. Please help me calculate the time duration
    By JackyG_01 in forum Excel General
    Replies: 6
    Last Post: 11-14-2012, 11:13 AM
  5. calculate shift duration
    By jeffbrown1966 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-29-2010, 09:13 AM
  6. How to calculate duration of time
    By annlanding in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-11-2006, 12:38 PM
  7. [SOLVED] Calculate Duration.
    By Art in forum Excel General
    Replies: 6
    Last Post: 09-04-2005, 09:05 PM

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