+ Reply to Thread
Results 1 to 10 of 10

Figuring total hours in military time going passed midnight.

  1. #1
    Registered User
    Join Date
    07-07-2012
    Location
    OKLAHOMA
    MS-Off Ver
    365
    Posts
    31

    Figuring total hours in military time going passed midnight.

    I need a formula for figuring military time passed midnight.

    Our day shift starts at 0500 and ends around 1900. The night shift starts around 1700 and ends around 0700 the next day. All i need is total hours. Right know for the day shift i use the formula

    =(text(e3,"00\:00")-text(d3,"00\:00"))*24. Im putting this in column "i". When leaving blank leaves a 0 which is fine. For the days this is ok.

    For the nights i just added a +1 which leaves me a 24 in column "i" when e and d are left blank. Need to show 0. Ive tryed several differant formulas havent had any luck.

    I need to calculate total ticket times which again my problem is the night shift. What i need is a formula if possible that can be used for tickets that might end before midnight or tickets that may end sometime after midnight or tickets that may start after midnight and ending after.

    Dont know if possible for a formula to do all three so can use one across the board. For this reason we have contract workers that may start at any time.

    I need one complicated formula to do one simple thing. Just one to be able to calculate totals hours with any military time put in.

    If anyone can help me with this it would be very appreciated.

    Thanks

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Figuring total hours in military time going passed midnight.

    Maybe ...

    =IF(COUNT(D3:E3)<2, "", 24*MOD(TEXT(E3,"00\:00") - TEXT(D3,"00\:00"), 1))
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Figuring total hours in military time going passed midnight.

    With start time in A2, end time in B2, this is the basic formula you will always use so the math handles "past midnight" correctly:

    =(B2-A2)+(B2<A2)


    Now, encase that in whatever formatting you wish. Perhaps:

    =((B2-A2)+(B2<A2))*24 ...formatted as General.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    07-07-2012
    Location
    OKLAHOMA
    MS-Off Ver
    365
    Posts
    31

    Re: Figuring total hours in military time going passed midnight.

    Thanks shg this worked what would i need to change to get to show in 1/4 hours.

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

    Re: Figuring total hours in military time going passed midnight.

    If you want to round the result to the nearest 0.25 (1/4 hour) then try this version

    =IF(COUNT(D3:E3)<2, "", ROUND(96*MOD(TEXT(E3,"00\:00") - TEXT(D3,"00\:00"), 1),0)/4)
    Audere est facere

  6. #6
    Registered User
    Join Date
    07-07-2012
    Location
    OKLAHOMA
    MS-Off Ver
    365
    Posts
    31

    Re: Figuring total hours in military time going passed midnight.

    Well this gave me the same result. We enter time in 1/4 hours need it to add and subtract in 1/4 hours dont want to round up or down.

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

    Re: Figuring total hours in military time going passed midnight.

    OK then, in that case I'm not sure what you mean by "what would i need to change to get to show in 1/4 hours".

    If you have 2115 in D3 and 0330 in E3 then that's a difference of 6 and a quarter hours so shg's formula should return a result of 6.25 - is that the result you want? What should it it show differently.....or can you give me an example where shg's formula doesn't give the result you want?

  8. #8
    Registered User
    Join Date
    07-07-2012
    Location
    OKLAHOMA
    MS-Off Ver
    365
    Posts
    31

    Re: Figuring total hours in military time going passed midnight.

    Yes that is correct. Shg's formula is rounding to the nearest 100 so 2115 to 0330 is showing 6.
    2100 to 330 showing 7 needs to be 6.5. 2145 to 330 showing 6 needs 5.75. Im copying and pasting
    what i have entered.

    =if(count(c7:d7)<2,"",24*mod(text(d7,"00\:00")-text(c7,"00\:00"), 1))

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

    Re: Figuring total hours in military time going passed midnight.

    I get 6.5 and 5.75 with those values (using that same formula). I assume you have the result cell formatted to show just a single digit - try re-formatting the cell to number with 2 decimal places

  10. #10
    Registered User
    Join Date
    07-07-2012
    Location
    OKLAHOMA
    MS-Off Ver
    365
    Posts
    31

    Re: Figuring total hours in military time going passed midnight.

    Well that was it i should have known that. Works like was wanting. Thank you guys so much.

+ 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