Forum Discussion

dlcartin's avatar
dlcartin
Iron Contributor
Mar 09, 2023
Solved

IF,AND,OR

I have the TODAY() function in cell C1 set to show the numerical value of the MONTH (1 - 12) and the same for C2 set to show the numerical value of the DATE (1 - EOM (30 or 31)). I've been trying to ...
  • SnowMan55's avatar
    Mar 09, 2023

    dlcartin If your conditional formatting (CF) formula is to compare dates, they (probably) can't all be based on the result of the TODAY function; one of them should be a fixed (stored) date.  Does G5 contain a fixed future date that you want to highlight when it is only 3 or 6 or 9 months away?

     

    In any case, the EDATE function is your friend.  So your CF formula for that cell might be:

     

    =OR( G5=EDATE(TODAY(),3), G5=EDATE(TODAY(),6), G5=EDATE(TODAY(),9) )

     

    Or if you still want to reference a cell containing "today's date" (that you can readily change the contents of, for testing the formula), replace TODAY() in that formula with $C$1.

     

    You will notice that EDATE calculates 3 months after 31 Mar as 30 Jun (not 01 Jul), and 3 months after 30 Nov 2023 as 29 Feb 2024 (not 01 Mar 2024).  If you need alternative results … yeah, then your cell and/or CF formula(s) will be a lot more complicated, with special logic for end-of-month in January (3-month), March (3-month, 6-month), May (6-month, 9-month), …

     

    Side note: If C1 contains =TODAY(), its value is (approximately) 44994, regardless of whether you have formatted it to display just the month number. Similarly for C2. To get those intended values, you would use =MONTH(TODAY()) and =DAY(TODAY()), respectively.

     

     

     

Resources