+ Reply to Thread
Results 1 to 12 of 12

Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    Fredon, NJ
    MS-Off Ver
    Excel for Office 365
    Posts
    19

    Question Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    The data is downloaded from the medical records. It puts the Admitted Date in C2 (10/1/2014) and Admit Time in D2 (605) should be 0605 anyway. Then Discharge Date in E2 (10/4/2015) and Discharge Time in F2 (1320). I am having problems getting it to calculate the total hours over the date span in military time. I really need help.

    .

  2. #2
    Forum Contributor stephenloky's Avatar
    Join Date
    07-10-2013
    Location
    Sao Paulo - Brazil
    MS-Off Ver
    Excel 2007
    Posts
    146

    Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    Hello, can you post a sample workbook writing the expected input and output?
    "The quieter you become, the more you are able to hear"

    Any reputation (*) points appreciated.

    "If you know yourself but not the enemy, for every victory gained, you will suffer defeat."

  3. #3
    Registered User
    Join Date
    01-04-2013
    Location
    Fredon, NJ
    MS-Off Ver
    Excel for Office 365
    Posts
    19

    Question Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    Test.xlsx Here is a sample workbook of data. Thanks

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    See if this starts things in the right direction. Put in H2
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then format Custom [h]:mm.

    Are we close?
    Attached Files Attached Files

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    Use same formula/format G2
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    (different dates, though )

  6. #6
    Registered User
    Join Date
    06-18-2014
    Location
    houston, Texas
    MS-Off Ver
    2010
    Posts
    28

    Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    How about this?

    -Strother

    Solution 1.xlsx

  7. #7
    Registered User
    Join Date
    01-04-2013
    Location
    Fredon, NJ
    MS-Off Ver
    Excel for Office 365
    Posts
    19

    Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    Yes you got the time right, can you have it round to the nearest hour so if it comes back as 28:50 hours then it rounds to 28 hours but if it is 28:51 hours it takes it to 29 hours?

  8. #8
    Registered User
    Join Date
    01-04-2013
    Location
    Fredon, NJ
    MS-Off Ver
    Excel for Office 365
    Posts
    19

    Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    Thank you so much for the help both solutions work! I have been killing myself over this for 4 days.... Thanks again now my presentation for tuesday is done!
    I really appreciate all the help!

  9. #9
    Registered User
    Join Date
    01-04-2013
    Location
    Fredon, NJ
    MS-Off Ver
    Excel for Office 365
    Posts
    19

    Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    I am sorry to bug you again about this but this am when I plugged in the formula I am getting an error with only a few cells. it is when the admit time starts with a zero. Example (0:37). Is there a simple fix to this?
    I am using this formula: =($E2+REPLACE($F2,LEN($F2)-1,0,":"))-($C2+REPLACE($D2,LEN($D2)-1,0,":"))

    Otherwise it works great!

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    Quote Originally Posted by psunursingguy21 View Post
    I am sorry to bug you again about this but this am when I plugged in the formula I am getting an error with only a few cells. it is when the admit time starts with a zero. Example (0:37). Is there a simple fix to this?
    I am using this formula: =($E2+REPLACE($F2,LEN($F2)-1,0,":"))-($C2+REPLACE($D2,LEN($D2)-1,0,":"))

    Otherwise it works great!
    I didn't see that one coming. Apologies.

    The original post indicates the "times" present in the format 605 and 1320. Assuming 0:37 arrives as 37 this modified version of that formula works.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by FlameRetired; 06-07-2015 at 03:06 PM.

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    Try this formula to give the exact time difference

    =TEXT(F2,"00\:00")+E2-TEXT(D2,"00\:00")-C2

    ....or if you want it rounded to the nearest hour

    =ROUND((TEXT(F2,"00\:00")+E2-TEXT(D2,"00\:00")-C2)*24,0)/24
    Audere est facere

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Need to Calculate Total Hours from 2 date cells and 2 time cells in military time.

    @ daddylonglegs

    Yeah...much better!

+ 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. Cells with military time not adding hours right
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-11-2015, 11:09 AM
  2. [SOLVED] How do I get total hours from 2 date/time cells?
    By Rick Taylor in forum Excel General
    Replies: 4
    Last Post: 06-06-2006, 02:45 PM
  3. Calculate total Hours between 2 date and time
    By Tylim in forum Excel General
    Replies: 3
    Last Post: 05-08-2006, 10:20 PM
  4. Figuring military time for total hours
    By Barb Reinhardt in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-06-2005, 12:05 PM
  5. Figuring military time for total hours
    By David Nelms in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM

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