Sub topic 10
Highlighting dates and deadlines
This chapter assumes you can write a formula-based rule, you know how the Applies to range works, and you can tell relative, absolute and mixed references apart. Here you will apply them to dates. You will use the built-in date rule, then write formula rules for overdue items, upcoming deadlines, weekends and expiry windows. You will also learn why date rules sometimes silently fail.
How Excel stores dates
Excel stores a date as a serial number, the count of days since 1 January 1900. For example, 1 January 2026 is 46023. The date format only changes how the number is displayed. Date rules work because comparing two dates is the same as comparing two numbers.
Two consequences matter for conditional formatting:
- A date typed as text, such as
"2026-03-05"stored as a string, is not a number. Comparisons againstTODAY()give wrong results or never match. - A blank cell counts as 0, which is the earliest possible date. A rule like
=$D2<TODAY()is therefore true for every empty cell in the column.
TODAY() returns the current date with no time. NOW() returns the date and time, so a value with a time part never equals TODAY(). Both functions are volatile. Excel recalculates them whenever the workbook recalculates, so the highlighting updates when you reopen the file the next day.
The built-in "A Date Occurring" rule
The quickest option needs no formula.
- Select the date cells, for example
D2:D50. - Choose Home > Conditional Formatting > Highlight Cells Rules > A Date Occurring.
- Pick a period from the first list and a format from the second.
The available periods are Yesterday, Today, Tomorrow, In the last 7 days, Last week, This week, Next week, Last month, This month and Next month.
This rule has limits. It only tests the cell it formats, so it cannot look at a status column. Its periods are fixed, so you cannot ask for "within 10 days". For anything else, use a formula rule.
Formula rules for deadlines
To create a formula rule, select the range, choose Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format, and enter the formula. Write the formula as if you were typing it into the top-left cell of the selection. Excel adjusts it for every other cell.
The examples below assume a task list in A2:E50. Column D holds due dates and column E holds the status.
Overdue items
Start with the formula from the plan:
=AND($D2<TODAY(), $E2<>"Done")Applied to $A$2:$E$50, this highlights the whole row when the due date has passed and the status is not "Done". The $ before D and E locks the columns. The row number stays relative, so each row tests its own date and status.
This version highlights rows with no due date, because an empty cell is 0. Add a blank check:
=AND($D2<>"", $D2<TODAY(), $E2<>"Done")Due today, or due soon
A single day:
=$D2=TODAY()A window that starts today and runs seven days ahead:
=AND($D2>=TODAY(), $D2<=TODAY()+7, $E2<>"Done")The lower bound $D2>=TODAY() keeps overdue items out of this rule. Without it, every past date would also satisfy $D2<=TODAY()+7.
If your dates include a time of day, wrap the cell in INT to drop the time:
=INT($D2)=TODAY()Working days instead of calendar days
NETWORKDAYS counts weekdays between two dates, including both ends, and skips Saturday and Sunday. This rule highlights items due within three working days:
=AND($D2>=TODAY(), NETWORKDAYS(TODAY(), $D2)<=3, $E2<>"Done")You can pass a range of holiday dates as a third argument, for example NETWORKDAYS(TODAY(), $D2, Holidays!$A$2:$A$20). Rules can refer to other worksheets in current Excel versions. Older versions required a defined name for this.
Weekends and the current month
WEEKDAY with the second argument set to 2 numbers the days from Monday (1) to Sunday (7). Anything above 5 is a weekend:
=WEEKDAY($D2, 2)>5To match any date in the current month, compare both month and year. Comparing only the month would also match the same month in other years:
=AND(ISNUMBER($D2), MONTH($D2)=MONTH(TODAY()), YEAR($D2)=YEAR(TODAY()))Expiry windows
For contracts, certificates or stock, you often want a warning period. This rule highlights dates that are still in the future but expire within 30 days:
=AND(ISNUMBER($D2), $D2>=TODAY(), $D2-TODAY()<=30)ISNUMBER excludes blank cells and text. Subtracting two dates returns the number of days between them.
Layering several date rules
A common design uses three rules on the same range, each with a different fill:
| Rule | Formula | Fill |
|---|---|---|
| Overdue | `=AND($D2<>"", $D2<TODAY(), $E2<>"Done")` | Red |
| Due within 7 days | `=AND($D2>=TODAY(), $D2<=TODAY()+7, $E2<>"Done")` | Orange |
| Completed | `=$E2="Done"` | Gray, with gray font |
The conditions here do not overlap, so the order of the rules does not matter. Where conditions do overlap, the rule higher in the Rules Manager wins when both set the same property, such as fill color. Use Stop If True to prevent lower rules from applying at all.
Using a date cell instead of TODAY()
TODAY() always moves. For a report that should be checked against a fixed date, such as a month-end, put the date in a cell and refer to it with an absolute reference. Suppose H1 holds the as-of date:
=AND($D2<>"", $D2<$H$1, $E2<>"Done")Both the column and row of $H$1 are locked, so every cell compares against the same value. You can change the date in one place and the whole sheet updates. It also makes the rule easier to test, because you can type a past or future date into H1 and watch the highlighting change.
Troubleshooting date rules
| Symptom | Likely cause | Fix |
|---|---|---|
| Nothing is highlighted | Dates are stored as text | Convert them with **Data > Text to Columns** or `DATEVALUE`. Left-aligned dates are a warning sign. |
| Empty cells are highlighted | Blank cells count as 0 | Add `$D2<>""` to the formula. |
| Wrong rows are highlighted | Row reference is off by one | Make sure the formula refers to the first row of the Applies to range. |
| Only one column highlights | Column reference is relative | Use `$D2`, not `D2`. |
| "Due today" misses items | Values include a time | Use `INT($D2)=TODAY()`. |
| Highlight is stale | Manual calculation mode | Press F9, or set **Formulas > Calculation Options > Automatic**. |
To check what a cell contains, type =ISNUMBER(D2) in a spare cell. It returns TRUE for a real date and FALSE for text.
Exercise
A project list has start dates in column C (C2:C100) and a status in column F. Write a formula rule that highlights the whole row A2:F100 when the start date is in the next 14 days (including today) and the status is not "Started". It should ignore rows with no start date. What do you enter, and why is the column reference written as $C2?
Show answer
Select A2:F100 with A2 as the active cell and use =AND(ISNUMBER($C2), $C2>=TODAY(), $C2<=TODAY()+14, $F2<>"Started"). ISNUMBER excludes blank and text cells. The $ locks column C so every cell in a row tests that row's start date, and the row number stays relative so each row tests its own values.
Exercise
A rule =$D2<TODAY() on D2:D50 highlights the empty cells D30:D50 as well as real past dates. Why does this happen, and how do you fix it?
Show answer
An empty cell is treated as 0, which is earlier than today, so the comparison is true. Change the rule to =AND($D2<>"", $D2<TODAY()).