+ Reply to Thread
Results 1 to 8 of 8

Using Today() function but getting unexpected results

  1. #1
    Registered User
    Join Date
    10-08-2020
    Location
    Devon, UK
    MS-Off Ver
    16.41 on MacBook Air
    Posts
    4

    Using Today() function but getting unexpected results

    Hi there, it is 8th October today, so why does the formula below return the false value? (US date format)

    =if(today()>"10/01/20","Yes we are past the 1st October","No we are not past the 1st October")

    I'm using a MacBook Air, but the same result happens in EXCEL or Google Sheets.

    If I change the mathematic inequality to 'less than' it obviously returns the true value, but I just can't see why.

    Thanks

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Using Today() function but getting unexpected results

    If your computer is set to UK regional settings, then the date will be taken as 10th January. To be on the safe side, you could use:

    DATE(2020,10,1)

    Hope this helps.

    Pete

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Using Today() function but getting unexpected results

    Remove the quotation marks from the date

    =IF(TODAY()>10/1/20,"Yes we are past the 1st October","No we are not past the 1st October")
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    10-08-2020
    Location
    Devon, UK
    MS-Off Ver
    16.41 on MacBook Air
    Posts
    4

    Re: Using Today() function but getting unexpected results

    That was it. Bugged me for ages.

    I was actually combining Today() with Datedif to show the number of weeks that have progressed within a calendar month, but then fixing once the month is over. Seems that Datedif needs quotes otherwise it is treated as a number, but Today() is clearly indifferent.

    =if(Today()>9/30/20,round(datedif("9/1/20","9/30/20","D")/7,1),datedif("9/1/20",today(),"D")/7)

    Thank you ever so much!

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Using Today() function but getting unexpected results

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

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  6. #6
    Registered User
    Join Date
    10-08-2020
    Location
    Devon, UK
    MS-Off Ver
    16.41 on MacBook Air
    Posts
    4

    Re: Using Today() function but getting unexpected results

    Fab - thanks again - I was just trying to see how to close this off!

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Using Today() function but getting unexpected results

    That formula (the Today()>9/30/20 part) is not doing what you think it is. Try changing the 20 to 2050 and it will still evaluate the TRUE part. It's treating it as a division, not a date. You should use the DATE function as already suggested.
    Rory

  8. #8
    Registered User
    Join Date
    10-08-2020
    Location
    Devon, UK
    MS-Off Ver
    16.41 on MacBook Air
    Posts
    4

    Re: Using Today() function but getting unexpected results

    Thanks rorya,

    you were correct - the unquoted date was being treated as an equation.

    I now have the today function comparing its value to a given date using the date function and it is working as I would expect.

    Thanks again.

+ 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. DateValue function presenting unexpected results in VBA
    By Coldry in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-07-2019, 02:42 PM
  2. Creating string with for loop and if function - unexpected results
    By eg0e in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-22-2015, 10:15 AM
  3. [SOLVED] Unexpected results from MSQuery
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-10-2014, 11:09 AM
  4. LINEST function unexpected results
    By guffaw320 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-05-2013, 02:46 PM
  5. Offset function with unexpected results
    By Coaster in forum Excel General
    Replies: 10
    Last Post: 07-01-2010, 04:09 AM
  6. INT function returns unexpected results
    By 6StringJazzer in forum Excel General
    Replies: 9
    Last Post: 03-24-2010, 08:24 PM
  7. The ispmt function is providing unexpected results
    By Louis Zaffino in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-02-2006, 11:10 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