+ Reply to Thread
Results 1 to 13 of 13

Military date time group subtraction

  1. #1
    Registered User
    Join Date
    12-08-2013
    Location
    Little Rock, Arkansas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Military date time group subtraction

    Hello, I'm in the process of trying to subtract two military date time groups. For example say A1 is 060810DEC13 and A2 is 072300DEC13. How would I subtract these two items so that we can get the time in hours?

    Thanks

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

    Re: Military date time group subtraction

    What does 072300DEC13 represent as a date and time?
    Entia non sunt multiplicanda sine necessitate

  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: Military date time group subtraction

    Hi and welcome to the forum

    I think you have the day inthe 2nd date wrong (00 Dec?)
    Assuming it was meant to be 10 Dec (doesnt really matter, just as long as the day is valid), try this...
    This converts A to a proper date/time...
    =DATEVALUE(RIGHT(A2,7))+TIMEVALUE(LEFT(A2,2)&":"&MID(A2,3,2))
    And this does the same to A2...
    DATEVALUE(RIGHT(A1,7))+TIMEVALUE(LEFT(A1,2)&":"&MID(A1,3,2))

    Therefor...
    =DATEVALUE(RIGHT(A2,7))+TIMEVALUE(LEFT(A2,2)&":"&MID(A2,3,2))-DATEVALUE(RIGHT(A1,7))+TIMEVALUE(LEFT(A1,2)&":"&MID(A1,3,2))
    should give you what you want?
    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
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Military date time group subtraction

    Maybe

    A
    B
    1
    060810DEC13
    2
    072310DEC13
    3
    1:15
    A3: =(RIGHT(A2,7) & TEXT(LEFT(A2, 4), " 00\:00")) - (RIGHT(A1,7) & TEXT(LEFT(A1, 4), " 00\:00"))

  5. #5
    Registered User
    Join Date
    12-08-2013
    Location
    Little Rock, Arkansas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Military date time group subtraction

    Thank you both for your assistance, but my question is still left un-answered. And I have no idea how to better explain or get to the answer I need. From what I've seen, most are under the impression that a military date time group (DTG) is represented by DDMMMYY HH:MM. However, this is very much incorrect.

    With the US Military DTG, the following is represented:

    DDHHMMMMMYY
    DD = Date
    HHMM = Time (in 24 hours format)
    MMM = Month
    YY = Year

    FD, your formula changed all dates to the first day of the month. The rest of the formula converted someone correctly.

    Shg, what you suggest only shows a 1 hour, 15 minute difference. In reality, by looking at the day(s) in the example, it should be a total difference of 39 hours. Your formula does not allow for the advancement of time into the following day. 8:10 AM on Dec 6, to 11:10 PM on Dec 7 is a total of 39 hours.

    Again, thank you both for your assistance, but it looks like I have a lot more research to do.

  6. #6
    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: Military date time group subtraction

    FD, your formula changed all dates to the first day of the month. The rest of the formula converted someone correctly.
    Break it up into 2 steps then...

    A
    B
    C
    1
    060810DEC13
    12/10/2013 06:08
    1:15:00
    2
    072310DEC13
    12/10/2013 07:23


    B1=DATEVALUE(RIGHT(A1,7))+TIMEVALUE(LEFT(A1,2)&":"&MID(A1,3,2)) copied down

  7. #7
    Registered User
    Join Date
    12-08-2013
    Location
    Little Rock, Arkansas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Military date time group subtraction

    I agree, but the formula in B1 & B2 shows a date of 12/10/2013 when the date in A1 is (translated) 12/06/13 and B1 is 12/07/13. So your formula changes all the dates to the 10th of the month while a previous suggestion changed all the dates to the 1st of the month.

  8. #8
    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: Military date time group subtraction

    aahh ok I missed that the DD was 1st, so day/hour/month-month/year

    change my formula to this, copied down...
    =DATEVALUE(LEFT(A1,2)&RIGHT(A1,5))+TIMEVALUE(MID(A1,3,2)&":00")
    then B2=B1 = 39

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,937

    Re: Military date time group subtraction

    In Name manager, Define name: MONTHNAMES ----> ={"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"}
    Then, with 060810DEC13 in A1:
    Please Login or Register  to view this content.


    Data Range
    A
    B
    C
    1
    060810DEC13
    12/06/2013 08:10
    DATE(RIGHT(A2,2)+2000,MATCH(MID(A2,7,3),MONTHNAMES,0),LEFT(A2,2))+TIME(MID(A2,3,2),MID(A2,5,2),0)
    2
    072300DEC13
    12/07/2013 23:00
    3
    38:50:00
    Ben Van Johnson

  10. #10
    Registered User
    Join Date
    12-08-2013
    Location
    Little Rock, Arkansas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Military date time group subtraction

    And apparently I screwed something up. I'm getting [#VALUE!] in the cell that I'm putting the formula in. I've gone to "format cells" and changed the settings several times, but continue to get the same thing.

  11. #11
    Registered User
    Join Date
    12-08-2013
    Location
    Little Rock, Arkansas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Military date time group subtraction

    ProtonLeah,

    When I use what you provided I keep getting #N/A. It must be something I'm doing on my end.

  12. #12
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Military date time group subtraction

    welcome to the forum, elothian. which formula did you use? if you're getting VALUE, there's no point formatting cells. you can try this formula too:
    =--(LEFT(A2,2)&RIGHT(A2,5))+TEXT(MID(A2,3,4),"00\:00")-(--(LEFT(A1,2)&RIGHT(A1,5))+TEXT(MID(A1,3,4),"00\:00"))

    upload a sample file to show us what you've got

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  13. #13
    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: Military date time group subtraction

    Correction....
    A
    B
    C
    1
    060810DEC13
    12/6/2013 08:10
    38:50:00
    2
    072300DEC13
    12/7/2013 23:00


    B1=DATEVALUE(LEFT(A1,2)&RIGHT(A1,5))+TIMEVALUE(MID(A1,3,2)&":"&MID(A1,5,2)) copied down

+ 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] Covert date/time to military time hour only
    By toontown in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-03-2013, 01:05 PM
  2. 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
  3. Replies: 5
    Last Post: 10-28-2010, 03:24 PM
  4. Military time subtraction
    By mattcr40 in forum Excel General
    Replies: 6
    Last Post: 12-06-2007, 12:21 PM
  5. Date Subtraction/Time between Occurences
    By Losse in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-15-2005, 01:32 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