+ Reply to Thread
Results 1 to 25 of 25

Subtracting military time formatted as text

  1. #1
    Registered User
    Join Date
    08-25-2015
    Location
    Dallas, Texas
    MS-Off Ver
    2010
    Posts
    14

    Subtracting military time formatted as text

    I would like to calculate the time difference between military time formatted as text without converting the times to numerical values - with the output in standard hours/minutes. Is this doable?

    NEWDELTIME OLDDELTIME HRSVARIANCE Comments
    2145 2100 45 Correct - the time difference should be 45 min
    2315 2230 85 Incorrect - the time difference should be 45 min
    0030 2345 2315 Incorrect - the time difference should be 45 min

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    Try

    =MOD(TEXT(A2,"00\:00")-TEXT(B2,"00\:00"),1)*1440

  3. #3
    Valued Forum Contributor
    Join Date
    11-02-2016
    Location
    NY
    MS-Off Ver
    2010
    Posts
    459

    Re: Subtracting military time formatted as text

    Generally "Anything may be possible" however, to actually do it may require a LOT of work! Generally, I would use military time as Decimal values...so in your examples, I would use 21.75 for 2145; 23.25 for 2315; .5 for 0030 and 23.75 for 2345. You will still need to make allowances for times not on the same DAY as in YOUR last example (perhaps add 25 hours to 0030??), but calculations would be much smoother!

  4. #4
    Registered User
    Join Date
    08-25-2015
    Location
    Dallas, Texas
    MS-Off Ver
    2010
    Posts
    14

    Re: Subtracting military time formatted as text

    Thanks, the calculation works most of the time.

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    You're welcome.

    Can you post examples of times it doesn't work, Including the results you expected ?

  6. #6
    Registered User
    Join Date
    08-25-2015
    Location
    Dallas, Texas
    MS-Off Ver
    2010
    Posts
    14

    Re: Subtracting military time formatted as text

    NEWDELDAY NEWDELTIME OLDDELDAY OLDDELTIME New Formula Hrs
    MON 2015 MON 2200 1335 22.25
    WED 0630 WED 0900 1290 21.5
    WED 0345 WED 0730 1215 20.25
    MON 2315 MON 2100 135 2.25
    MON 2215 TUE 0030 1305 21.75
    (see attachment)
    Attached Files Attached Files

  7. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    And what's the problem?
    Which cells are not returning the value you expected ? what was the value you expected ?

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    Do you want the result to be shown in an actual time format ?
    Remove the *1440 and format the cell with the formula as a time hh:mm

  9. #9
    Valued Forum Contributor
    Join Date
    11-02-2016
    Location
    NY
    MS-Off Ver
    2010
    Posts
    459

    Re: Subtracting military time formatted as text

    See attached. There looks like some issues with your data (no punch out or NA) and you need to ASSUME if the Punch out time is Less than Punched in time to compensate (Example: orig Punch in 11:00pm or 2300 hours with Punch out on next day at 9:00am or 0900 ~ Add 24 hours to the In time: (0900 + 2400)- 2300 = 1000 or 10 HOURS.

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    I see the mistake now.

    In your original post, you had the times listed as
    LaterTime EarlierTime

    So I wrote it as A-B (LaterTime-EarlierTime)


    But in the book you posted, you have the times as
    EarlierTime LaterTime
    But you still did A-B (or B-D), which ended up as EarlierTime-LaterTime

    You need to reverse the math to D-B

    =MOD(TEXT(D2,"00\:00")-TEXT(B2,"00\:00"),1)*1440

    And again, remove the *1440 and format the cell as TIME if you want it shown in a real time formulat hh:mm

  11. #11
    Registered User
    Join Date
    08-25-2015
    Location
    Dallas, Texas
    MS-Off Ver
    2010
    Posts
    14

    Re: Subtracting military time formatted as text

    Thanks, but the time is neither older or later - just different. I want to know the difference in time. It looks as though if the new time is later than the old time the formula is B-D. If the new time is earlier than the old time the formula is D-B. So now I need an IF statement. Oh wow!

  12. #12
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    There is always an earlier and later when comparing times.
    Maybe it would be clearer to say which time occurred first ?? The one in B or the one in D ?

    Your time stamps must relate to something, like a Check in and a Check out time..
    One of them happened first.

    Think about a watch.

    Is there 4 or 8 hours between 10 and 2

    Either is correct. It depends on which occurred first.
    If you're measuring time from 10 to 2, then it's 4.
    If you're measuring time from 2 to 10, then it's 8.

  13. #13
    Registered User
    Join Date
    08-25-2015
    Location
    Dallas, Texas
    MS-Off Ver
    2010
    Posts
    14

    Re: Subtracting military time formatted as text

    The times are routing changes in ETAs.

  14. #14
    Registered User
    Join Date
    08-25-2015
    Location
    Dallas, Texas
    MS-Off Ver
    2010
    Posts
    14

    Re: Subtracting military time formatted as text

    The old time is the current ETA. The new time will be the new ETA.

  15. #15
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    So my question is...

    Are you trying to measure how much time is from B to D, or from D to B ??

  16. #16
    Registered User
    Join Date
    08-25-2015
    Location
    Dallas, Texas
    MS-Off Ver
    2010
    Posts
    14

    Re: Subtracting military time formatted as text

    D to B - old time to new time

  17. #17
    Valued Forum Contributor
    Join Date
    11-02-2016
    Location
    NY
    MS-Off Ver
    2010
    Posts
    459

    Re: Subtracting military time formatted as text

    USE A DATABASE!! Or use standard formatting conventions

  18. #18
    Registered User
    Join Date
    08-25-2015
    Location
    Dallas, Texas
    MS-Off Ver
    2010
    Posts
    14

    Re: Subtracting military time formatted as text

    D to B, Old time to New time.

  19. #19
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    OK, so it needs to be B-D then.

    =MOD(TEXT(B8,"00\:00")-TEXT(D8,"00\:00"),1)*1440

    You said that works 'most of the time'

    Then you posted a new book showing the formula I suggested
    Which cells in the book you posted in Post #6 were not correct ? And what should the correct answer have been ?

  20. #20
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    Or use standard formatting conventions
    Yes, This.


    I'm now seeing huge problems...
    We need to consider the DAY as well.

    Take Row 13 and 18 (in the book you posted in post #6)
    Row 13 A = Mon C = Tue Is the Difference here Mon Tue, or Tue Wed Thur Fri Sat Sun Mon ??
    Row 18 A = Wed C = Tue Is the Difference here Wed Thu Fri Sat Sun Mon or Tue Wed ??


    You need to use complete Date and Time Stamps.
    Real Dates and Real Times.

    Yes I know it's more key strokes to enter a date and time (with the
    But it's worth it in the long run.

  21. #21
    Registered User
    Join Date
    08-25-2015
    Location
    Dallas, Texas
    MS-Off Ver
    2010
    Posts
    14

    Re: Subtracting military time formatted as text

    I am trying to measure how much time is from D to B (old time to new time)

  22. #22
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    See post #19

  23. #23
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,994

    Re: Subtracting military time formatted as text

    If you are interested in the difference between times without regard to dates:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Ben Van Johnson

  24. #24
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    If you're going to do Max-Min, then you don't need the mod anymore.

    I don't see how we can disregard the date here. And I'm trying desperately to get the OP to give some greater detailed explaination.

    If these are ETA, estimated time of arrival.
    And comparing the old ETA with a new updated ETA.

    We need to know which came first.
    Is the NEW ETA In the Future or Past as related to the original ETA ?
    i.e. Does the new ETA mean the task is being completed sooner than the original ETA, or later ?

    The fact that Days are listed at all (Mon Tue etc..)
    And many of them are different from the Old ETA the New ETA.

    I think it's imperitave for the OP to redesign how this is written, and use REAL dates and Times to log the old ETA vs the new ETA.
    Last edited by Jonmo1; 08-03-2017 at 05:12 PM.

  25. #25
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Subtracting military time formatted as text

    Take row 18 in the latest book just posted.

    OLD ETA = TUESDAY 2330
    NEW ETA = WEDNESDAY 0145

    That formula gives 21 hours and 45 minutes. But that's only considering if both eta's are on the same day.
    But since the NEW eta is on Wednesday, the difference is really only 2 hours and 15 minutes.

+ 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. Adding/Subtracting military time
    By criticalmass in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-20-2013, 03:38 PM
  2. Military time subtracting
    By 86gts in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-03-2012, 11:42 PM
  3. Simple way to convert military time to standard where military has no colon
    By salvator in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2011, 10:27 AM
  4. Military Time DTG subtracting
    By joesport5 in forum Excel General
    Replies: 2
    Last Post: 07-21-2011, 01:26 PM
  5. converting military time to EDT and subtracting time from one cell to another
    By niklas24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-03-2010, 09:41 AM
  6. Subtracting Military Time, with output in minutes
    By pink in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-13-2007, 02:43 AM
  7. [SOLVED] Change text to military time
    By gobonniego in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-21-2006, 06:30 PM
  8. Subtracting Cells formatted with Date AND Time to get hours?
    By mcr1 - ExcelForums.com in forum Excel General
    Replies: 1
    Last Post: 07-05-2005, 05: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