+ Reply to Thread
Results 1 to 7 of 7

Negative Time Formula

  1. #1
    Forum Contributor
    Join Date
    12-17-2008
    Location
    Vernon, CT
    Posts
    132

    Question Negative Time Formula

    I can't use 1904. I have a formula that almost works
    I am doing everything in Military time. This is the finial peice of the puzzle.

    Our shift begins at 18:00 and ends up until 7:00 (am) or so depending onwork

    A1 I have a time (Projected-Estimate of when all work should be done)
    A2 I have a time (Actual- Time the work was actually complete.)
    A3 Will be show the difference in either a Negative or Positive time.

    Three Examples: (The first two work as is and are perfect)

    A1 2:11 (Projected)
    A2 2:23 (Actual)
    A3 0:11 (Difference) 11 min over projected. (Formula below)

    =IF(A1 < A2,TEXT(MAX($A$1:$A$2)-MIN($A$1:$A$2),"h:mm"),TEXT(MAX($A$1:$A$2)-MIN($A$1:$A$2),"-h:mm"))


    A1 2:23 (Projected)
    A2 2:11 (Actual)
    A3 -0:11 (Difference) 11min under projected.

    So far this is excellent. This issue comes when:

    A1 23:22 Projected
    A2 1:22 Actual
    A3 -22:00 which should be 2:00

    I know =mod will work for that case but not if it were 23:00 projected and 22:00 actual.

    So with the formula that I am using =IF(A1 < A2,TEXT(MAX($A$1:$A$2)-MIN($A$1:$A$2),"h:mm"),TEXT(MAX($A$1:$A$2)-MIN($A$1:$A$2),"-h:mm"))

    How do I get it to tell be the difference while showing a - or + number in military time if it transends the next day? I was trying to add more "if" statements in there but can't get it to work.

    Thanks for attempting this if it is possible.
    Last edited by jayclinton; 12-30-2009 at 08:26 PM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Negative Time Formula Getting Too Complicated

    So far this is excellent. This issue comes when:

    A1 23:22 Projected
    A2 1:22 Actual
    A3 -22:00 which should be 2:00
    If A2 means to convey that it's actually later than A1, then you need to incorporate that into A2. How is A2 arrived at? Excel needs to determine that the time in A2 is actually on the following day compared to the time in A1, so you may need to include not just the time but also the date into your calculations.

    If you can post an example of your spreadsheet, I'm sure we'll work something out!

    cheers

  3. #3
    Forum Contributor
    Join Date
    12-17-2008
    Location
    Vernon, CT
    Posts
    132

    Re: Negative Time Formula Getting Too Complicated

    I have attached a worksheet of only what I need done. My projected end time comes from a ton of other formulas that takes many factors into account. Then it will give a time in A2. That is all set. Then I would enter the actual time in. This would be when we actually completed all the work. Then C2 will tell me the difference including if it was over or under "x" amount.

    I was trying to add in Mod and if's because seperately I can get a Mod to work. Like =Mod((C2-B2),1) would work for one way and b2-c2 works for if the numbers are reversed, but I can't incorporate everything to get it to work. I am not sure if I explained that well enough.
    Attached Files Attached Files

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Negative Time Formula Getting Too Complicated

    I think you need to include the date into the equation, to make sure Excel can differentiate that if a time in B is smaller than a time in A, it is on the same day or not.

    Then, change your formula in column C to

    =IF(A2 < B2,TEXT(MAX(A2:B2)-MIN(A2:B2),"[h]:mm"),TEXT(MAX(A2:B2)-MIN(A2:B2),"-[h]:mm"))

    note the [] brackets around "h" which will show hours greater than 24.

    See attached, where the values in A and B include dates as well as time.

    hth

  5. #5
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Negative Time Formula

    U can also use 1904 date system if u want display negative time.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Negative Time Formula

    ContaminatedWit: read the very first sentence of this thread!

  7. #7
    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: Negative Time Formula

    Another alternative: =DOLLARFR(24*(A2-B2), 60)

    To convert back to time, =DOLLARDE(that result, 60) / 24
    Entia non sunt multiplicanda sine necessitate

+ 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