How to Display YES or NO Based on Date in Excel
Question details
The user wants to output the text YES or NO based on whether a date meets a certain condition, rather than trying to read the cell's conditional formatting color.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Evaluating dates in a spreadsheet to generate text labels instead of relying on conditional formatting colors.
- Observed behavior
- Excel formulas cannot directly read or evaluate a cell's background color reliably, so the underlying date logic must be used to generate the output instead.
Identify the exact logical condition used for your existing conditional formatting (e.g., date is older than 45 days). Ensure your target column where the YES or NO will appear is formatted as General text.
Use the IF Function to Evaluate the Date Logic
Replicate the conditional formatting logic inside an IF statement to return YES or NO based on the date.
Because standard Excel functions cannot directly detect cell colors applied by conditional formatting, the most reliable method is to evaluate the data itself. By using the exact same date condition that triggers the color change, you can output specific text strings.
Click on the cell where you want the YES or NO text to appear (e.g., cell E2 next to your date in D2).
Type the formula =IF(D2="","",IF(D2<=TODAY()-45,"YES","NO")). This formula first checks if the cell is blank to prevent errors, then checks if the date is at least 45 days old relative to today.
Press Enter to calculate the result, then drag the fill handle at the bottom-right corner of the cell down to copy the formula to the remaining rows in your dataset.

Effortlessly Manage Date Formulas with WPS Spreadsheet
WPS Spreadsheet offers robust formula support, allowing you to easily evaluate date conditions and apply both logical text outputs and conditional formatting seamlessly.
- 1. Open your document: Launch WPS Spreadsheet and open the file containing your date values.
- 2. Enter the IF formula: Select the target cell and input =IF(D2="","",IF(D2<=TODAY()-45,"YES","NO")) into the formula bar.
- 3. Copy the formula: Drag the fill handle down to apply the logic across your entire dataset instantly.

Frequently Asked Questions
Can Excel formulas return a value based on a cell's conditional formatting color?
Standard Excel functions cannot directly read or evaluate a cell's background color or font color applied by conditional formatting. You must use the underlying data logic (like a specific date range) to return values.
How do I change the condition from 45 days to another number?
Simply replace the number 45 in the formula =IF(D2<=TODAY()-45,"YES","NO") with your desired number of days, such as 30 or 60, depending on your project requirements.
Why does my date formula return an error or incorrect value for blank cells?
If you only use =IF(D2<=TODAY()-45,"YES","NO"), blank cells are treated as zero (January 0, 1900), which is always less than today's date. Adding IF(D2="","",...) at the beginning prevents this by leaving the cell blank if there is no date entry.




