+ Reply to Thread
Results 1 to 15 of 15

IF time is between two times return value

  1. #1
    Forum Contributor
    Join Date
    09-21-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    131

    IF time is between two times return value

    Why IF formula still returning false even if now time false between user input?

    time.png

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF time is between two times return value

    Many members are unable to see images in the *.png format due to forum compatibility issues with some browsers.

    If you need to post an image post it in the *.jpg format.

    Even better than posting images... post a SMALL sample file. That way we can test solutions directly in the file with the relevant data.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Contributor
    Join Date
    09-21-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    131

    Re: IF time is between two times return value

    Reuploaded using jpeg format.

    sample_time.jpg
    Attached Files Attached Files

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,146

    Re: IF time is between two times return value

    I'm not getting the same error. It works here. Not certain what the difference is with yours. sorry.
    Attached Files Attached Files

  5. #5
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,249

    Re: IF time is between two times return value

    Try
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  6. #6
    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. 2412 (Windows 11 24H2 64-bit)
    Posts
    88,707

    Re: IF time is between two times return value

    It's the same here and I believe it has something to do with the NOW() function including the date, although I'm not sure. Just as an aside, in an IF statement with TRUE and FALSE, you do not need inverted commas:

    =IF(AND(A1>C1,A1<D1),TRUE,FALSE)
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  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. 2412 (Windows 11 24H2 64-bit)
    Posts
    88,707

    Re: IF time is between two times return value

    Quote Originally Posted by avk View Post
    Try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    That doesn't do what is required. The OP's formula works with a time entered manually: the problem is with the NOW() function.

  8. #8
    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. 2412 (Windows 11 24H2 64-bit)
    Posts
    88,707

    Re: IF time is between two times return value

    Quote Originally Posted by avk View Post
    Try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    That doesn't do what is required. The OP's formula works with a time entered manually: the problem is with the NOW() function.

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: IF time is between two times return value

    You don't need to to use IF statement in this case
    Just this
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Formula will return TRUE or FALSE
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  10. #10
    Forum Contributor
    Join Date
    09-21-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    131

    Re: IF time is between two times return value

    Tried everything what you have suggested. But it doesn't work. It works if you replace A1 to static time but it doesn't work when its in now() format. And this is crucial to me as formula has to run based on current time.

  11. #11
    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. 2412 (Windows 11 24H2 64-bit)
    Posts
    88,707

    Re: IF time is between two times return value

    What has been suggested by AlKey and myself won't change anything, and avk's suggestion is just wrong. I'm afraid I don't know how to make Excel treat the NOW() value in the same way as a manually input time. I've tried custom formatting, but it makes no difference. However, I have just tried this and it works (this is in cell A1):

    =TIME(TEXT(NOW(),"HH"),TEXT(NOW(),"MM"),0)

  12. #12
    Forum Contributor
    Join Date
    09-21-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    131

    Re: IF time is between two times return value

    Problem solved:


    With the =Now() formula you are getting back the current date and time. The manually entered times represent the time on 1/1/1900.

    Change your =Now() formula to

    =Now()-Int(Now())

    Then it will return the time without the date portion and your comparison will work.

  13. #13
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: IF time is between two times return value

    You have to use MOD with NOW in A1
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  14. #14
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,146

    Re: IF time is between two times return value

    The only way I could get it to show today's date was using :

    Please Login or Register  to view this content.

  15. #15
    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. 2412 (Windows 11 24H2 64-bit)
    Posts
    88,707

    Re: IF time is between two times return value

    Quote Originally Posted by Logit View Post
    The only way I could get it to show today's date was using :

    Please Login or Register  to view this content.
    Today's date was not what was required. It was the time now that the OP wanted.

+ 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] Creating a graph with start times and end times vs time
    By khoadphamm in forum Excel General
    Replies: 14
    Last Post: 12-31-2019, 02:57 PM
  2. Replies: 4
    Last Post: 10-20-2016, 12:48 PM
  3. Replies: 2
    Last Post: 06-11-2015, 04:01 AM
  4. [SOLVED] VBA Program works some times and some times gives me a Run-time error '1004'?
    By redsab in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-13-2014, 11:15 PM
  5. Less then, return zero, equal or higher return value times 2 plus 50
    By Simale in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-25-2014, 09:42 AM
  6. If a search term can be found 1 time, 2 times 3 times 4 times 5 times
    By excelcandy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2013, 09:57 PM
  7. Replies: 3
    Last Post: 07-26-2012, 10:50 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