TechBuzzPro

Conditional Formatting Dates Overlap?

· 5 min read · Apps & Browsers

In this article
  1. Formula
  2. Worked Example
  3. How to Apply This in Excel or Google Sheets
  4. Why the Simple Rule Fails
  5. Common Mistakes and Pitfalls
  6. Alternatives: Using SUMPRODUCT for Multiple Rows
  7. Frequently Asked Questions

Yes, you can use conditional formatting to highlight overlapping date ranges in Excel or Google Sheets, but the built-in rules don't do it directly—you need a custom formula. This article explains how to build that formula, common pitfalls, and how to adapt it for different scenarios.

in start | Start date | - | 2024-01-01 | 0
in end | End date | - | 2024-01-10 | 0
in check_start | Check start | - | 2024-01-05 | 0
in check_end | Check end | - | 2024-01-15 | 0
out overlap | Overlap days | days | max(0, min(end, check_end) - max(start, check_start) + 1) | 0

Formula

Two date ranges overlap if the later of the two start dates is on or before the earlier of the two end dates. In formula terms:

Overlap = MAX(0, MIN(end1, end2) - MAX(start1, start2) + 1)

Where:

  • start1, end1 – the first date range (e.g., a project or booking).
  • start2, end2 – the second date range (e.g., the range you're checking against).
  • All dates are treated as whole days; the result is the number of overlapping days.

If the result is 0, the ranges do not overlap. If it's positive, they share at least one day.

Worked Example

Using the default values from the calculator:

  • Range 1: Jan 1 to Jan 10
  • Range 2: Jan 5 to Jan 15

Step 1: Find the later start date: MAX(Jan 1, Jan 5) = Jan 5

Step 2: Find the earlier end date: MIN(Jan 10, Jan 15) = Jan 10

Step 3: Subtract: Jan 10 - Jan 5 = 5 days, then add 1 to include both endpoints = 6 days.

So the overlap is 6 days (Jan 5 through Jan 10 inclusive).

How to Apply This in Excel or Google Sheets

Conditional formatting with a custom formula works the same way in both Excel and Google Sheets, but the exact steps differ slightly.

In Excel:

  1. Select the range of cells that contain your start dates (e.g., A2:A100).
  2. Go to Home → Conditional Formatting → New Rule → Use a formula to determine which cells to format.
  3. Enter a formula like =SUMPRODUCT((A2<=END_RANGE)*(B2>=START_RANGE))>1 (adjust ranges to your data).
  4. Click Format, choose a fill color, and click OK.

In Google Sheets:

  1. Select the range (e.g., A2:A100).
  2. Go to Format → Conditional formatting → Add new rule.
  3. Under “Format cells if,” choose “Custom formula is.”
  4. Enter the same type of formula, then set the formatting style.

The key is to write the formula relative to the top-left cell of your selection. For example, if your data starts at A2, write the formula as if for A2, and Sheets/Excel will adjust it for each row.

Why the Simple Rule Fails

Many people try to use a built-in rule like “Cell Value Between” to check if a date falls within a range. That works for a single date, but not for a range of dates. For example, if you have a booking from Jan 1 to Jan 10 and another from Jan 5 to Jan 15, checking if Jan 5 is between Jan 1 and Jan 10 will return TRUE, but it won't tell you that the second booking overlaps the first—it only checks one date.

To detect overlap, you need to compare two pairs of dates simultaneously. The formula MAX(start1, start2) <= MIN(end1, end2) is the standard test. If it returns TRUE, the ranges overlap.

Common Mistakes and Pitfalls

  • Using < instead of <= – If one range ends exactly when another starts, they don't overlap in terms of shared days. But if you treat dates as inclusive (i.e., a booking on Jan 10 and another starting Jan 10 share a day), use <=. Decide which behavior you need.
  • Forgetting to lock cell references – In Excel, use absolute references (e.g., $A$2) where needed, but relative references for the current row. In Google Sheets, the same logic applies.
  • Applying the rule to the wrong range – If you select both start and end columns, the formula must account for that. Usually, you apply the rule to the start column only, or to the entire row, but then you need to adjust the formula accordingly.
  • Date formatting issues – If your dates are stored as text, the formula won't work. Ensure they are real date values (right-aligned in the cell).

Alternatives: Using SUMPRODUCT for Multiple Rows

If you have a list of many ranges and want to highlight any that overlap with any other, you can use a more advanced formula. In Excel, the following array formula (entered with Ctrl+Shift+Enter in older versions) checks if the current row overlaps with any other row:

=SUMPRODUCT((A2<=B$2:B$100)*(B2>=A$2:A$100))>1

This counts how many other rows have a start date before the current end date AND an end date after the current start date. If the count is greater than 1 (including itself), it means there's at least one overlap.

In Google Sheets, the same formula works without special entry, as it handles array formulas natively.

Frequently Asked Questions

How do I highlight overlapping dates in Excel?

Select your date range, create a new conditional formatting rule with a custom formula like =SUMPRODUCT((A2<=B$2:B$100)*(B2>=A$2:A$100))>1 (adjust ranges), and set a fill color. This highlights any row that overlaps with another.

What if my dates include times?

If your dates have times, the overlap formula still works, but you must be careful with the “+1” day adjustment. For time-based ranges, use MAX(0, MIN(end1, end2) - MAX(start1, start2)) and format the result as a time duration.

Can I use conditional formatting to find gaps between dates?

Yes, but that's a different formula. To find gaps, you'd compare each start date to the previous end date. For example, =A2>B1 would highlight if there's a gap between the end of the previous row and the start of the current row.

Why does my conditional formatting not work when I copy it to other cells?

Most likely because your formula uses relative references incorrectly. When you apply the rule to a range, the formula should be written relative to the active cell (usually the top-left of the selection). If you copy the rule to another range, adjust the references accordingly.

Is there a way to highlight all overlapping ranges at once?

Yes, the SUMPRODUCT method described above does exactly that. It checks each row against all other rows and highlights any that have at least one overlap.