+ Reply to Thread
Results 1 to 5 of 5

Military Time Difference formula...Help!

  1. #1
    Registered User
    Join Date
    07-30-2008
    Location
    Minnesota
    Posts
    12

    Military Time Difference formula...Help!

    Hi,

    I'm stuck on how to get this is work out correctly.

    I have two columns that contain military time.

    depending on the entry, the first column may be larger than the second and in other scenarios it's vice versa..

    e.g.

    Column A = 24:00
    Column B = 06:00

    Eg. Midnight to 6am. e.g. diff of 6 hours

    or

    Column A = 10:00
    Column B = 18:00

    eg. 10am to 6pm. e.g. diff of 8 hours

    I need to have a formula that checks to see if A is larger than B and then calculates the difference and then in the same formula if B is larger than A then calculates the difference, etc.

    I was playing around with this.. =(B2-A2)*24 but that only works if column B is larger than A. Otherwise I end up with negative numbers, etc.

    Is there not a forumula that allows you to have a true and false and rather than a static value, allow you to have two seperate formulas based upon the true and false condition??

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Military Time Difference formula...Help!

    =if(a1=b1,formula if true,formula if false)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    07-30-2008
    Location
    Minnesota
    Posts
    12

    Re: Military Time Difference formula...Help!

    not sure that will work....


    basically I was thinking it should be like this...

    if A1>A2 then (A1-A2) * 24, if A2>A1 then (A2-A1) * 24

    But not sure how that would go into a Formula.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Military Time Difference formula...Help!

    i take it thats meant to be
    if A1>A2 then (A1-A2) * 24, if A2<A1 then (A2-A1) * 24
    if(a1>a2,(a1-a2)*24,(a2-a1)*24)
    it doesnt matter if a1=a2 as result will be 0 a2-a1=0
    Last edited by martindwilson; 08-06-2009 at 09:00 AM.

  5. #5
    Registered User
    Join Date
    05-22-2009
    Location
    Sheffield, UK
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Military Time Difference formula...Help!

    Not sure if this is what you mean but try
    =((B1-A1)+(B1<A1))*24

+ 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