+ Reply to Thread
Results 1 to 8 of 8

Time less than - Why do I always get false outcome?

  1. #1
    Registered User
    Join Date
    10-11-2011
    Location
    Iceland
    MS-Off Ver
    Excel 2007
    Posts
    20

    Time less than - Why do I always get false outcome?

    Greetings everybody,

    I was wondering if you could help me with one problem.
    I cannot for the life of me understand why I always get false out of this formula.

    A1 = 00:50 (formatted as time)

    I put the following formula in B1

    B1 = IF(A1<TIME(01;10;0);YES;NO)

    So I read this like, 00:50 < 01:10 - which is true. Why does excel always return "NO" (false outcome) ?

    Many thanks in advance guys!
    Hjorrip
    Last edited by Hjorrip; 09-02-2015 at 10:50 AM. Reason: Changing prefix

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

    Re: Time less than - Why do I always get false outcome?

    What's the value in A1 if it's formatted as General?

    I expect it includes a date.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Time less than - Why do I always get false outcome?

    Manually doing this on my PC results in a YES.

    I suspect the value 00:50 in A1 is currently recorded with a date in it. e.g. 1/Jan/2015 00:50 but formatted to just show 00:50.
    Change your formatting in A1 a number and see what it says. You should have a number that is between 0 and 1 in order for it to say YES.

  4. #4
    Registered User
    Join Date
    10-11-2011
    Location
    Iceland
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Time less than - Why do I always get false outcome?

    Thanks guys.
    I know what is causing this, but I'm not sure how to fix that (I did the easy way of explaining when I started the thread, turns out that my example was just fine, but not what i was actually doing)

    So I'm calculating how much time I can spend, depending on what time I can start, and what time I must finish.

    I have 4 cells

    A1 = Time I start (Time formatted) = 23:30
    B1 = Time I finish (Time formatted) = 00:30
    C1 = Duration (time formatted). Difference between A1 and B1 is 1 hour. I dont want any value in C1 if B1 is empty. I had problems with the time calculation due to midnight overpass, so I entered the following formula: This is where my error must be: =IF(ISBLANK(B1);"";IFERROR((B1+24)-A1;B1-A1))

    And lastly, I use the formula to say yes or no if the time is less than TIME(1;10;0) - even though A3 shows only 01:00, i still get a false value when its suppose to be positive.

    D1 = =IF(C1<TIME(1;10;0);"YES";"NO")

    Values:
    A1 = 23:30
    B1 = 00:30
    C1 = =IF(ISBLANK(B1);"";IFERROR((B1+24)-A1;B1-A1)) - Shows 01:00 with this formula'
    D1 = =IF(C1<TIME(1;10;0);"YES";"NO") - Shows NO, I want to see YES

    Thanks in advanced,
    Hjorrip
    Last edited by Hjorrip; 09-02-2015 at 05:41 AM.

  5. #5
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: Time less than - Why do I always get false outcome?

    Hi,

    It should be (B1+1) & not (B1+24)

    correct the formula as following: also, custom format C1 to [hh]:mm:ss

    =IF(ISBLANK(B1),"",IFERROR((B1+1)-A1,B1-A1))

    24 = 576:00:00 hours

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Time less than - Why do I always get false outcome?

    With that method
    IFERROR((B1+1)-A1,B1-A1)

    If the time does NOT span midnight (a1 is 5:00 b1 is 7:00)
    It will result in a time greater than 24 hours
    Because (B1+1)-A1 is NOT an error, therefor it does not go to the standard B1-A1 part.
    So B1+1 = 7 hours + 24 hours
    (7 hours + 24 hours)-5 hours = (31 hours) - 5 hours. = 26 hours = 1 day 2 hours

    Here's a very simple and common method for dealing with subtraction of times that span midnight.

    MOD(B1-A1,1)

    So try
    =IF(B1="","",MOD(B1-A1,1))
    Last edited by Jonmo1; 09-02-2015 at 08:56 AM.

  7. #7
    Registered User
    Join Date
    10-11-2011
    Location
    Iceland
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Time less than - Why do I always get false outcome?

    Thanks Jonmo1!

    That did the job, everything is working perfectly now!

    Thanks so much!

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Time less than - Why do I always get false outcome?

    You're welcome.

+ 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] Run Time error ‘1004’: .Refresh BackgroundQuery:=False
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-06-2014, 12:37 AM
  2. [SOLVED] "FALSE" result outcome problem
    By Christopherdj in forum Excel General
    Replies: 2
    Last Post: 08-04-2014, 08:55 PM
  3. Run-time error '1004' for .Refresh BackgroundQuery:=False for loop
    By Robo25 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2013, 01:16 AM
  4. Run-Time error '1004' .refresh background query:= False
    By batador in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-24-2013, 06:00 AM
  5. Generate a time series outcome
    By Ericng in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-09-2013, 04:50 AM
  6. Two lists to compare in one worksheet and requiring a True/False Outcome
    By laura21_1983 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-28-2012, 12:23 PM
  7. Replies: 2
    Last Post: 10-24-2011, 04:49 PM

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