+ Reply to Thread
Results 1 to 6 of 6

Formula to return a True/False if date equals yesterday's date

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    23

    Formula to return a True/False if date equals yesterday's date

    I have "Completed Date" under column M in the format of the following:

    2/5/2013 11:23:07 AM (m/d/yyyy h:mm under Custom number format)

    I want to add another column next to it that will return the word "TRUE" or "FALSE" if the order was completed the day before regardless of the time that is shown in "Completed Date" so that I can use a filter to show only the TRUE results and the FALSE to be hidden.

    I'm not familiar with writing my own formulas so I started with the following:

    =IF(TODAY()-1=M2,TRUE,FALSE)

    It is returning all FALSE and I believe it's because of the time that is added to the date. This is how the data is exported so I'd rather not change the formats for all the dates to make this work unless I can create another column that can automatically convert the date format to something that is workable for what I'm trying to achieve (ie. changing 02/05/2013 12:26:24 PM to a simply read 02/05/2013).

    Not trying to complicate things further, but we only want to include business days so if it was Monday today, yesterday would be considered Friday so we'd want to see Friday's results.

    Any help is greatly appreciated. Thanks very much.
    Last edited by abbeycrombie; 02-05-2013 at 02:32 PM.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,677

    Re: Formula to return a True/False if date equals yesterday's date

    You can get just the date by using INT function, i.e.

    =IF(TODAY()-1=INT(M2),TRUE,FALSE)

    .....but you don't really need the IF function, just use

    =TODAY()-1=INT(M2)
    Audere est facere

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Formula to return a True/False if date equals yesterday's date

    abbeycrombie,

    You were close, give this a try:
    =IF(TODAY()-1=INT(M2),TRUE,FALSE)

    Simplified:
    =(TODAY()-1=INT(M2))


    Also, instead of using the TODAY() function in a formula, I would recommend having a separate cell that contains this formula:
    =TODAY()-1

    Then just reference that cell in your main formula. Because TODAY() is volatile, it will get recalculated any time there is a change to the workbook. So only having a single cell with that volatile function will save on workbook calc time and resources. If the cell containing the TODAY() function is A1:
    =($A$1=INT(M2))


    [EDIT]: dll beat me to it
    Last edited by tigeravatar; 02-05-2013 at 02:36 PM. Reason: Added edit
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    01-18-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Formula to return a True/False if date equals yesterday's date

    Thanks so much to the both of you.

    I'm still getting a FALSE return. I was thinking that this might because of the added timestamp to the "Completed Date" column. For instance, entering =TODAY()-1 in the new Column N is now showing me 2/4/2013 0:00 but "Completed Date" under Column M has 2/4/2013 11:23:07 AM. I'm going to assume that these two are not the same even if the actual dates are the same because of the timestamp.

    Also, not sure if either of you saw the edit I made, but they want to only see business days so if today was Monday, "yesterday" would be considered Friday. Would this complicate things?

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,677

    Re: Formula to return a True/False if date equals yesterday's date

    Try this

    =WORKDAY(M2,1)=TODAY()

    WORKDAY will ignore the time in M2 and simply return the next working day (so on Friday it returns the following Monday)

  6. #6
    Registered User
    Join Date
    01-18-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Formula to return a True/False if date equals yesterday's date

    Thank you for the suggestions!! This helped me to get my report going and it has slowly evolved into something much more involved. I wouldn't have been able to do it without your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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