Function Problems

How to Check If One Date Range Falls Within Another in Excel

Aamir Naveed AkramAamir Naveed Akram Nov 10, 2026 870 views

Question details

Determine if one specific date range (such as a leave period) falls completely inside a corresponding master date range based on a shared ID.

How to Check If One Date Range Falls Within Another in Excel
Product
Excel
Device & OS
not provided
Scenario
Comparing datasets in scenarios like HR scheduling, timesheets, or project tracking to ensure a given activity's start and end dates fit perfectly within an authorized window.
Observed behavior
Successfully outputs a designated label (such as 'Leave') when an inner date range is strictly bounded by an outer date range for a specific identifier.
Before you start

Ensure that your dates are formatted as valid Excel Date values rather than text strings, and verify that both your source dataset and target dataset share a common identifier column (like an Employee ID).

Solution 1Recommended

Use IF and COUNTIFS to Verify Date Boundaries

This standard and highly compatible method uses the COUNTIFS function to match an ID and check if the start and end dates satisfy the boundary conditions of the outer date range.

The most straightforward way to check if one date range is fully encapsulated by another is by using the COUNTIFS function wrapped inside an IF statement. This evaluates multiple criteria simultaneously: an ID match, a start date greater than or equal to the master start date, and an end date less than or equal to the master end date.

1
Organize your datasets

Ensure you have two distinct areas or sheets for your data. For example, a 'Data' sheet containing the outer boundaries (Master Start and End Dates) and a 'Leave' sheet containing the inner boundaries (Leave Start and End Dates).

2
Select the destination cell

Click on the cell in your 'Data' sheet where you want the result (e.g., "Leave" or blank) to appear.

3
Enter the COUNTIFS formula

Type the formula: =IF(COUNTIFS(Leave!$A$2:$A$44850,"="&Data!$A2, Leave!$B$2:$B$44850,"<="&Data!C2, Leave!$C$2:$C$44850,">="&Data!D2)>0,"Leave",""). Adjust the sheet names and cell references according to your actual workbook layout.

4
Apply the formula

Press Enter to execute the formula, then double-click or drag the fill handle in the bottom-right corner of the cell to copy the formula down the entire column.

Use IF and COUNTIFS to Verify Date Boundaries
Formula Breakdown: The COUNTIFS function counts rows where all conditions are met. If the count is greater than 0, the IF function outputs 'Leave'. The criteria operators ('<=', '>=') are enclosed in quotes and concatenated (&) with cell references.
Efficient Formula Calculation with WPS Spreadsheet

Easily Verify Complex Date Ranges in WPS Spreadsheet

WPS Spreadsheet fully supports advanced logical and date functions, including COUNTIFS, IF, MAP, and XLOOKUP. It provides a highly compatible, fast, and user-friendly environment to calculate complex date overlaps effortlessly without changing your workflow.

  1. 1. Open your workbook: Launch WPS Spreadsheet and open the file containing your date datasets.
  2. 2. Select the target cell: Click on the specific cell where you want to output the overlap check result.
  3. 3. Input the formula: Type your =IF(COUNTIFS(...)) logic directly into the formula bar and press Enter.
  4. 4. Drag to fill: Use the smart fill handle to rapidly apply the formula to the rest of your data rows.
100% compatible with Excel formulas (COUNTIFS, IF, XLOOKUP)High-performance calculation engine for processing large HR datasets seamlesslyFree access to powerful data analysis and reporting toolsLightweight application that runs smoothly on Windows, Mac, Linux, and mobile
QA img-9

Frequently Asked Questions

Why is my COUNTIFS formula returning a 0 or error when comparing dates?

This typically occurs if your dates are formatted as text instead of recognizable numerical dates. Select your date columns, format them correctly as 'Short Date', or use the 'Text to Columns' feature under the Data tab to convert text strings into standard dates.

How do I check if date ranges partially overlap instead of completely falling within one another?

To check for a partial overlap, the logic shifts slightly. Two date ranges overlap if the first start date is less than or equal to the second end date, and the first end date is greater than or equal to the second start date. Adjust your COUNTIFS logic to '<=' and '>=' accordingly.

Can I use SUMPRODUCT instead of COUNTIFS for older spreadsheet versions?

Yes, if you need strict backward compatibility, SUMPRODUCT is an excellent alternative. An equivalent structural formula is =IF(SUMPRODUCT((Leave_ID=Data_ID)*(Leave_Start>=Data_Start)*(Leave_End<=Data_End))>0, "Leave", "").

How do I highlight dates that fall within another range automatically?

You can achieve this using Conditional Formatting. Select the date cells, navigate to 'Home' > 'Conditional Formatting' > 'New Rule', choose 'Use a formula to determine which cells to format', and input a logical formula (like your COUNTIFS logic without the IF wrapper) to apply a background fill color.