+ Reply to Thread
Results 1 to 11 of 11

24h time cross midnight; Nested IF not working for an earlier time

  1. #1
    Registered User
    Join Date
    01-08-2019
    Location
    California
    MS-Off Ver
    10
    Posts
    6

    24h time cross midnight; Nested IF not working for an earlier time

    A2= 0:15 (12:15am in 24h time)

    B2=0:14

    Formula:

    =IF(B2<A2, (B2+1)-(A2), (B2-A2))

    I keep getting "1439 min" as result; however if the B2 cell time is BEFORE A2, I want the result to be "0 min" ..I cannot get the nested IF statement to do what I need. (This formula works great for crossing midnight and all times if A2 is consistently before B2 and I need to keep this base-formatting for when the time's cross midnight (i.e. A2= 23:55, B2= 00:05 = "10 min")). My goal is to count everything in minutes (not h:mm) i.e A2=23:00 B2=00:15 = "75 min"

    My cell format is [m] "min"

    I hope this makes sense. Any and all suggestions are appreciated

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: 24h time cross midnight; Nested IF not working for an earlier time

    Hmm... this is a contradiction as I read it?

    First you say:

    however if the B2 cell time is BEFORE A2, I want the result to be "0 min"

    Then:

    My goal is to count everything in minutes (not h:mm) i.e A2=23:00 B2=00:15 = "75 min"

    in your last statement B2 IS before A2, yet you want that to result in 0 min AND 75 min...

    Without a date in the field to establish whether B2 is REALLY before A2, I don't see how the formula can do both things.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    01-08-2019
    Location
    California
    MS-Off Ver
    10
    Posts
    6

    Re: 24h time cross midnight; Nested IF not working for an earlier time

    I'm sorry it is hard to describe which is why the IF needs to be in there... I am very green to excel and in a new development program with my company and trying to build spreadsheets from scratch..

    Yes, I need to count minutes, however, if b2 time is Less than a2 time, I want the result to just be "0", not the 1439 as I am getting with the current formula.

    formula.png

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: 24h time cross midnight; Nested IF not working for an earlier time

    Ok but look at row 2 in your example... B2 actually is less than A2 time as you described. (I know that they are on different days, based on what you want it to come out as, but the computer doesn't know that)
    Also, B4 is AFTER A4... yet you want 0?

    I do believe I understand what you WANT but without a date to go with a time, I don't see that it can be done?
    Last edited by Arkadi; 01-08-2019 at 02:46 PM.

  5. #5
    Registered User
    Join Date
    01-08-2019
    Location
    California
    MS-Off Ver
    10
    Posts
    6

    Re: 24h time cross midnight; Nested IF not working for an earlier time

    Ah a date... true... the date is not included, just times :-/

    ok so without a date... can I add a nested formula to say "if the number is over 1000, make it 0" ?

    Thank you so much for your response. This has been driving me nuts now for 2 days and in the end, this spreadsheet is going to be very long...I really hope this can be done!

  6. #6
    Registered User
    Join Date
    01-08-2019
    Location
    California
    MS-Off Ver
    10
    Posts
    6

    Re: 24h time cross midnight; Nested IF not working for an earlier time

    (Oh and b4 is actually BEFORE A4 in this example....however it is the date that this formula does not know...which is 100% my mistake on not thinking about how the computer would read it.... so simple (duh!))

  7. #7
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,483

    Re: 24h time cross midnight; Nested IF not working for an earlier time

    Edit: some posts between the moment I started my reply and posted it so I might be doubling up a bit

    Hi bren84, one thing to remember about excel is that time is always a fraction of 1.

    So although you human brain sees 0:14 as after 23:00 but for Excel that 0:14 is before 23:00

    the fractional value of 0:14 is ~0,00972222222
    the fractional value of 23:00 is ~0,95833333333

    So you need to "reset your brain" from human logic to computer logic to get too the right formula.

    Same as Arkadi I do not see how you can built this in 1 formula.
    I think you need to set a limit where if the sum is over lets say 100 min is set to 0 min.

    you may need to explain more about the purpose of the calculation to get to the final result you need.
    Last edited by Roel Jongman; 01-08-2019 at 03:06 PM.

  8. #8
    Registered User
    Join Date
    01-08-2019
    Location
    California
    MS-Off Ver
    10
    Posts
    6

    Re: 24h time cross midnight; Nested IF not working for an earlier time

    Roel, Yes thank you. Staring as so many numbers and devising formulas I lost the "computer thinking" behind this formula. And yes I was wondering if I can set a limit just as you suggested! I can't get the formula right as I was adding it as a nested IF.... How/where can I set a limit if sum is over 1000?

  9. #9
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: 24h time cross midnight; Nested IF not working for an earlier time

    Try this one then:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    01-08-2019
    Location
    California
    MS-Off Ver
    10
    Posts
    6

    Re: 24h time cross midnight; Nested IF not working for an earlier time

    Quote Originally Posted by Arkadi View Post
    Try this one then:

    Please Login or Register  to view this content.
    OMG!!! It works! I tried it MULTIPLE ways and its PERFECT! Thank YOU!!! I don't think I would have ever been able to come up with the .69xx value (honestly, I'm not even sure how you even obtained that #) but I somehow knew there should have been a 2 and 3rd nested value I just couldn't put my finger on it.

    Thanks again Arkadi!!

  11. #11
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: 24h time cross midnight; Nested IF not working for an earlier time

    0.694444444444445 is what 1000 minutes is out of 24 hrs

    Thanks for marking the thread as solved and for the rep points

+ 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] VLookup to return value for time hh:mm not working past midnight
    By RayRay248 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 01-25-2021, 06:05 AM
  2. [SOLVED] Want to extract time before and after midnight for a time range that spans midnight
    By schurchill39 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-26-2018, 04:18 PM
  3. [SOLVED] Time Calculation When Working Past Midnight That Rounds W/Lunch Punches
    By blinhart in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-01-2018, 12:36 PM
  4. [SOLVED] Employees working past midnight - Time sheet dilemma
    By MacHead in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 11
    Last Post: 12-18-2015, 01:07 PM
  5. VLOOKUP not working when time goes past midnight.
    By zerocool2311 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-13-2014, 08:15 PM
  6. [SOLVED] Time calculation not working past midnight
    By Sophie.Durrant in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-08-2014, 08:18 PM
  7. Replies: 1
    Last Post: 06-30-2010, 07:48 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