+ Reply to Thread
Results 1 to 9 of 9

IF Function - Greater Than, Less Than with Times

  1. #1
    Registered User
    Join Date
    04-27-2019
    Location
    Los Angeles,CA
    MS-Off Ver
    Office 2010
    Posts
    21

    IF Function - Greater Than, Less Than with Times

    I need help figuring out why the below formula is not returning the right value. I'm using the formula to determine if trailers are being loaded on time. We use military time for our times and the formula works fine until you reach 00:00. After that everything shows up as late or on time depending on the time. The cells are formatted for time but I still get the same results. In the example you can see that the LRT is 15:30 and Ready Time was 15:00 so trailer was ON TIME. LRT on next one was also 15:30 and Ready Time was 02:36(am) so trailer should've been late but i get on Time. The same for the other two. The last two should both say On Time because they were both done before 00:00 but the 17:30 says late. I've looked but can't seem to find a solution. Any help will be greatly appreciated.


    N3 P3 R3
    LRT Ready Time Trailer Status

    15:30 15:00 ON TIME
    15:30 02:36 ON TIME

    00:00 17:30 LATE
    00:00 23:15 ON TIME

    Formula on R3
    =IF(P3<=N3,"ON TIME",IF(P3>N3,"LATE"))

  2. #2
    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
    52,939

    Re: IF Function - Greater Than, Less Than with Times

    Hi, welcome to the forum

    LRT on next one was also 15:30 and Ready Time was 02:36(am) so trailer should've been late but i get on Time.
    N3=15:30
    P3=02:36
    =IF(P3<=N3,"ON TIME"
    P3 is indeed < N3, so the answer should be On Time, the same as for P2=15:00

    Seeing as you only really have 2 tests, the 2nd IF is redundant
    =IF(P3<=N3,"ON TIME","LATE")
    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

  3. #3
    Registered User
    Join Date
    04-27-2019
    Location
    Los Angeles,CA
    MS-Off Ver
    Office 2010
    Posts
    21

    Re: IF Function - Greater Than, Less Than with Times

    Hi FDibbins,

    Thanks for the welcome and reply. I've been looking at it and I don't think there is a way to solve my problem. You are right the formula is working because technically 2am is earlier that 15:30 therefore it's on time. The problem is that it's 2am the next day. The 15:30 is the day prior so the 2am ready time is Late. I've been searching but I don't thinks there's a way around that.

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: IF Function - Greater Than, Less Than with Times

    If 2:36 is next day, you should store it as 26:36 ( and format as h:mm to display 2:36 if needed)
    Similar to 0:00 is 24:00
    then use your formula.
    Another way, if hour of next day never exceed, i.e 6:00 AM of next day, use this:
    N3 should be: = N3+IF(N3<=6/24,1,0)
    P3 should be: =P3+IF(P3<6/24,1,0)
    Then use:

    =IF(N3+IF(N3<=6/24,1,0)-(P3+IF(P3<6/24,1,0))>0,"ON TIME","LATE")
    Quang PT

  5. #5
    Registered User
    Join Date
    04-27-2019
    Location
    Los Angeles,CA
    MS-Off Ver
    Office 2010
    Posts
    21

    Re: IF Function - Greater Than, Less Than with Times

    Thanks bebo021999. That formula worked perfectly. Thanks for your help.

  6. #6
    Registered User
    Join Date
    04-27-2019
    Location
    Los Angeles,CA
    MS-Off Ver
    Office 2010
    Posts
    21

    Re: IF Function - Greater Than, Less Than with Times

    I ran into a problem. The formula works perfect but I just realized that sometimes P3 will stay blank and N3 will not and I need for those to say PENDING. Can I add an additional IF Function to the original to accomplish this?

    =IF(N3+IF(N3<=7/24,1,0)-(P3+IF(P3<7/24,1,0))>0,"ON TIME","LATE")


    P3.png

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: IF Function - Greater Than, Less Than with Times

    Try this:

    =IF(AND(P3="",N3<>""),"PENDING",IF(N3+IF(N3<=7/24,1,0)-(P3+IF(P3<7/24,1,0))>0,"ON TIME","LATE"))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  8. #8
    Registered User
    Join Date
    04-27-2019
    Location
    Los Angeles,CA
    MS-Off Ver
    Office 2010
    Posts
    21

    Re: IF Function - Greater Than, Less Than with Times

    Thank you so much AliGW . That worked great.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: IF Function - Greater Than, Less Than with Times

    No problem.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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] countif how many times greater than 1
    By swfarm in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-20-2019, 11:41 AM
  2. Highlighting value 3x times greater than average
    By Muz1993 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2016, 09:12 PM
  3. calculating times greater then 24 hours
    By webstersemail in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-17-2014, 09:54 PM
  4. [SOLVED] Comparing how many times one cell is greater than another on the same day
    By Araise in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-11-2014, 02:38 PM
  5. How to add dates and times greater than 24 hours
    By dvick in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-01-2014, 02:07 PM
  6. How to Find which one is greater between 2 times
    By anto1510 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 12-05-2010, 06:47 AM
  7. Elapsed times greater than 24hrs
    By NDBC in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2009, 12:57 AM

Tags for this Thread

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