# How to Check If a Date Is Within 7 Days of Another Date in Excel (7 Methods)

## Dataset Overview

We’ll use the following dataset to demonstrate the methods. The dataset contains three columns: Product, Order Date and Delivery Date.

### Method 1 – Use of IF Function

• Select a new cell (let’s say E5) where you want to display the result.
• Enter the following formula in cell E5:
`=IF((D5-C5)<7,"Successful","Late")`

Formula Breakdown

Here,

• (D5-C5)<7 checks if the difference between the dates in cells D5 and C5 is less than 7.
• If true, it returns Successful; otherwise, it returns Late.

• Press ENTER to get the result.

• Drag the Fill Handle icon to autofill the formula for the remaining cells (E6:E11).

### Method 2 – Using the DAYS Function

• Select a new cell (E5).
• Enter the formula:
`=DAYS(D5,C5)`

This calculates the duration in days between the end date (D5) and the start date (C5).

• Press ENTER to get the result.

• Double-click the Fill Handle icon to autofill the formula for the other cells (E6:E11).

### Method 3 – Combining Functions

• Choose a new cell (E5).
• Enter this formula:
`=IF(AND((TODAY() - C5) - 7 > 0,C5<TODAY()), "Done", "Processing")`
• Press ENTER to see the result.

Formula Breakdown

• TODAY() returns the current date.
• The AND function checks two conditions:
• (TODAY() – C5) – 7 > 0: Ensures the date difference is greater than 7 days.
• C5 < TODAY(): Verifies that the start date (C5) is before today.
• If both conditions are met, it returns Done; otherwise, it’s Processing.

• Autofill the formula for the other cells (E6:E11).

### Method 4 – Applying IF & AND Functions

• Select a new cell (let’s say E5) where you want to display the result.
• Enter the following formula in cell E5:
`=IF(AND(D5<=\$D\$13,(D5-C5)<=7),"Successful","Late")`
• Press ENTER to get the result.

Formula Breakdown

• Here:
• D5<=\$D\$13 ensures that the delivery date is less than or equal to the target date in cell D13.
• (D5-C5)<=7 checks if the difference between the dates in cells D5 and C5 is less than or equal to 7.
• If both conditions are met, it returns Successful; otherwise, it returns Late.

• Drag the Fill Handle icon to autofill the formula for the remaining cells (E6:E11).

### Method 5 – Employing Conditional Formatting

• Select the data range (D5:D11) for which you want to apply conditional formatting.
• Go to the Home tab and click on Conditional Formatting.
• Choose New Rule…

• In the New Formatting Rule dialog box, select Use a formula to determine which cells to format.
• Enter the formula:
`=(D5-C5)<7`

This formula checks if the difference between the dates in cells D5 and C5 is less than 7.

• Click on the Format button.

• In the Format Cells dialog box, choose a light color (e.g., Green) for the fill. Adjust font color if needed.
• Press OK to apply the formatting.

• Confirm by clicking OK on the New Formatting Rule dialog box. You’ll see the sample formatting in the Preview box.

• The colored dates within 7 days of another date will be visually highlighted.

### Method 6 – Using the Data Validation Tool to Know If a Date Is Within 7 Days of Another Date

• Select the cell range where you want to insert data.
• Go to the Data tab and click on Data Validation.
• Choose Data Validation…

In the Data Validation dialog box:

• Select Custom under Allow.
• Enter the formula:
`=(C5+7)>D5`
• This formula checks if adding 7 days to the start date (C5) results in a value greater than the end date (D5).
• Press OK to apply the validation.

You will see the following result.

### Method 7 – Use of “A Date Occurring” Feature

• Select the data range (D5:D11) for which you want to apply conditional formatting.
• Go to the Home tab and click on Conditional Formatting.
• Choose Highlight Cells Rules and select A Date Occurring…

• In the A Date Occurring dialog box:
• Choose In the last 7 days from the drop-down menu under Format cells that contain a date occurring:
• Select your preferred color (e.g., Green Fill with Dark Green Text).
• Press OK to apply the changes.

Now, the colored dates within 7 days of another date will be visually highlighted.

## Things to Remember

• If you simply want to check whether a date is within 7 days of another date, you can use method 2 (DAYS function).
• If you need a logical result based on the current date, consider using method 3 (a combination of functions).

## Practice Section

You can practice the explained methods by yourself.

<< Go Back to Dates | Compare | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Musiha Mahfuza Mukta

Musiha Mahfuza Mukta is a marine engineer who loves exploring Excel and VBA programming. To her, programming is a time-saving tool for dealing with data, files, and the internet. She's skilled in Rhino3D, Maxsurf, C++, MS Office, AutoCAD, and Excel & VBA, going beyond the basics. With a B.Sc in Naval Architecture & Marine Engineering from BUET, she's shifted gears and now works as a content developer. In this role, she creates techy content exclusively focused on Excel... Read Full Bio

We will be happy to hear your thoughts

Advanced Excel Exercises with Solutions PDF