Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Use Conditional Date Formatting in Excel

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Conditional date formatting in Excel allows you to automatically change the visual appearance of a cell based on its date value, such as highlighting overdue tasks or upcoming deadlines. This technique uses custom number formats combined with conditional logic to display dates differently without altering the underlying data. You do not need complex macros or VBA code; instead, you leverage Excel’s built-in Custom Number Format feature, which supports logical tests within the format string itself.

What You'll Need

  • Microsoft Excel installed on your computer (desktop version recommended for easiest access to menus).
  • A spreadsheet containing cells formatted as dates.
  • Basic understanding of Excel cell references and logical operators.

Step-by-Step

  1. Select the range of cells that contain the dates you want to format. Ensure these cells are already recognized by Excel as date values, not text.
  2. Open the Format Cells dialog box. You can do this by pressing Ctrl + 1 on your keyboard, right-clicking the selection and choosing "Format Cells," or navigating to the Home tab, clicking the small arrow in the bottom-right corner of the Number group.
  3. In the Format Cells window, ensure the Category list on the left is set to Custom. This reveals a Type field where you will enter your specific formatting code.
  4. In the Type field, clear any existing text. Enter a logical test using square brackets. For example, to highlight dates before today in red, type: [Red][<TODAY()]dd-mmm-yyyy. Note that menu labels may vary slightly depending on your Excel version and operating system.
  5. Press Enter or click OK to apply the format. The selected cells should now display dates in red if they are in the past, while future dates remain in the default black color.
  6. To add multiple conditions, separate them with semicolons. A common three-part format looks like this: [Red][<TODAY()]dd-mmm-yyyy;[Green][>=TODAY()]dd-mmm-yyyy. The first part applies if the condition is true, and the second part applies otherwise.
  7. Verify the results by changing a date value in one of the cells. If the date moves from the past to the future, the color should update immediately to reflect the new condition.

Common Mistakes

One frequent error is entering the formula incorrectly. Excel requires square brackets around both the color name and the logical operator. Writing Red < TODAY() will result in an error or simply display the text literally rather than applying the format. Another common issue is forgetting to select the correct category. If you stay in the "Date" category instead of switching to "Custom," you cannot input logical tests.

Users often confuse conditional formatting rules with custom number formats. While both can change colors, custom number formats only change how the number is displayed, whereas conditional formatting rules can change borders, fill colors, and font styles more broadly. Using the wrong tool for the job can lead to inconsistent styling across a large dataset.

Tips

You can use standard color names such as Red, Green, Blue, Black, and White directly in the format code. However, Excel does not support all web color names. Stick to the basic eight colors supported by older Excel versions to ensure compatibility when sharing files.

If you need to compare against a specific static date rather than the current day, replace TODAY() with the actual date serial number or a quoted date string, though using cell references is generally cleaner. For example, if cell B1 contains the cutoff date, you might use [Red][<$B$1]..., but note that direct cell references inside custom number formats are limited compared to conditional formatting rules.

For more complex visual changes, such as adding icons or background fills, consider using the native Conditional Formatting feature found under the Home tab > Conditional Formatting > New Rule. This method allows for greater flexibility but requires setting up rules via the ribbon interface rather than typing codes.

Troubleshooting

If the format does not apply, check that the cells actually contain date values. Sometimes dates imported from other systems are stored as text. To fix this, select the column, go to Data > Text to Columns, and finish the wizard without changing settings, or multiply the cells by 1 using Paste Special.

If the colors appear but the logic seems reversed, verify your comparison operators. Remember that < means less than (earlier) and > means greater than (later). Also, ensure there are no spaces between the brackets and the operators, as some Excel versions are sensitive to whitespace in format codes.

If the file opens correctly on your machine but displays errors on another, it may be due to regional settings affecting date separators. Standardize your date format using ISO-like structures (yyyy-mm-dd) within the custom format string to minimize cross-region issues.

Frequently Asked Questions

Can I use conditional date formatting in Google Sheets?

No, Google Sheets does not support logical tests within custom number formats. You must use the built-in Conditional Formatting feature under Format > Conditional formatting to achieve similar results.

Why doesn't my color change when I update the date?

Ensure you have pressed Enter after editing the cell. Excel updates custom formats dynamically, but if the cell is still in edit mode, the preview may not reflect the final state until you commit the change.

Can I combine text and dates in one custom format?

Yes, you can include literal text by enclosing it in double quotes. For example, "Due: "dd-mmm-yyyy will display the text "Due:" followed by the formatted date.

Does this affect sorting or filtering?

No, custom number formats only change the display. The underlying value remains a numeric date serial, so sorting and filtering operations continue to work based on the actual chronological order.

How do I remove the conditional formatting?

Select the cells, open the Format Cells dialog (Ctrl+1), go to the Custom category, and delete the code in the Type field. Then choose a standard format like "Short Date" or "Long Date" to reset the appearance.