+ Reply to Thread
Results 1 to 5 of 5

IF Statement Formulas with TODAY() and times

  1. #1
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    178

    IF Statement Formulas with TODAY() and times

    Hi All,

    I have a bunch of formulas which use IF statements and conditions involving dates which work great.

    For example:

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


    I discovered a slight issue whereby column A contains date and time in the following format ddmmyyyy hh:mm:ss

    Lets imagine A2 = 16/03/2022 12:05:10 and we are running the formula now (16/03/2022 22:18), the formula still returns "Valid" when in fact it should return "Expired" due to the time.

    It seems that the TODAY() function doesn't take into account the time attached to the date?

    How can I overcome this?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    36,690

    Re: IF Statement Formulas with TODAY() and times

    Maybe you need to use NOW() instead of TODAY().

    Or use INT(A2)

  3. #3
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    21,111

    Re: IF Statement Formulas with TODAY() and times

    Excel dates are stored as real numbers, where the decimal portion indicates the time of day.

    TODAY() returns an integer that represents today's date. It does not take time into account.

    If today is March 16, and you have a cell that shows 16/03/2022 12:05:10, that is >TODAY() and will result in "Valid".

    If you care about the time, not just the date, then use NOW() instead of TODAY(). That includes the current time.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    178

    Re: IF Statement Formulas with TODAY() and times

    Thank you for your prompt reply gents.

    NOW() seems to work so far. I need to apply it to my data and review to ensure there are no other suprises.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    36,690

    Re: IF Statement Formulas with TODAY() and times

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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] If statement with embedded Today() formula
    By Wozmatic in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-19-2021, 09:32 AM
  2. [SOLVED] If Statement using Today()
    By Lewisdavies94 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-04-2020, 10:01 AM
  3. Replies: 2
    Last Post: 04-28-2020, 09:22 AM
  4. Getting VBA IF statement to behave correctly with =TODAY()
    By Dylan87 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2015, 12:43 PM
  5. If statement - Need to stop the today's date calculation
    By crw reef in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-04-2014, 02:57 PM
  6. [SOLVED] If Statement for today being more than (x) days from cell value.
    By Sc0tt1e in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-18-2013, 07:49 AM
  7. Today Statement ignoring blank
    By safisam in forum Excel General
    Replies: 2
    Last Post: 04-23-2009, 10:01 AM

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