+ Reply to Thread
Results 1 to 5 of 5

Military Time Not Calculating after Midnight.

  1. #1
    Forum Contributor
    Join Date
    06-26-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    136

    Military Time Not Calculating after Midnight.

    I have three columns E, F and G

    Column E is Scheduled Arrival entered as a time in military time format
    Column F is Actual Time In entered as a time in military time format
    Column G shows any arrival Delays with the formula =IF((F5-E5)>0,(F5-E5),0)

    The problem is is when the Actual time is past midnight. So for example, Scheduled Arrival is 22:00, Actual Time in is 3:00 the arrival delay in column G needs to be 300 (in minutes).

    Thanks in Advance!

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

    Re: Military Time Not Calculating after Midnight.

    Presumably actual time could be early as well as late? These questions are always difficult because of the circular nature of time (for your example 03:00 could be 19 hours early rather than 5 late), so you need to make some assumptions.

    Let's assume that actual arrival time will never be more than 2 hours early (adjust as required) and use this formula for thee number of minutes late

    =IF(MOD(F5-E5+"2:00",1)-"2:00">0,MOD(F5-E5,1)*1440,0)
    Audere est facere

  3. #3
    Registered User
    Join Date
    07-16-2012
    Location
    Newcastle upon Tyne
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: Military Time Not Calculating after Midnight.

    You would need to include a date with your times, otherwise there is no way for Excel to see if 03:00 is 5 hours late, or 19 hours early. Alternatively, decide on a breaking point, for instance if it seems to be more than half a day early, then treat it as if it's late. e.g.: =MAX(F2+((F2+0.5)<E2)-E2,0)

    Of course if the actual time is always after the scheduled time, you could just use: =F2+(F2<E2)-E2
    Steve D. a.k.a. Stephen Dunn

  4. #4
    Forum Contributor
    Join Date
    06-26-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: Military Time Not Calculating after Midnight.

    Quote Originally Posted by daddylonglegs View Post
    Presumably actual time could be early as well as late? These questions are always difficult because of the circular nature of time (for your example 03:00 could be 19 hours early rather than 5 late), so you need to make some assumptions.

    Let's assume that actual arrival time will never be more than 2 hours early (adjust as required) and use this formula for thee number of minutes late

    =IF(MOD(F5-E5+"2:00",1)-"2:00">0,MOD(F5-E5,1)*1440,0)
    Thanks for the help, Im not familiar with this MOD function so hard for me to troubleshoot...but this returned a value of 432000 when it should be 300 (5 hours in min)

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

    Re: Military Time Not Calculating after Midnight.

    Using MOD here is a simple way to cope with time periods passing through midnight.

    I assume you have your result cell custom formatted as [m] - if you format as general you'll see 300....or if you want to leave the cell formatted as [m] then take out the multiplication by 1440, i.e. use

    =IF(MOD(F5-E5+"2:00",1)-"2:00">0,MOD(F5-E5,1),0)

+ 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. Calculating time difference over midnight!
    By sygazelle in forum Excel General
    Replies: 14
    Last Post: 05-28-2022, 04:20 PM
  2. [SOLVED] Figuring total hours in military time going passed midnight.
    By NETSPY in forum Excel General
    Replies: 9
    Last Post: 07-09-2012, 05:59 PM
  3. Calculating time after midnight
    By ryangodammit in forum Excel General
    Replies: 5
    Last Post: 12-09-2008, 11:57 PM
  4. [SOLVED] Calculating Time Past Midnight
    By Darren in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-13-2006, 11:03 AM
  5. Replies: 3
    Last Post: 01-17-2006, 01:55 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