Function Problems

Use an IF and OR Date Formula in Excel for Dates Within Six Months

Khadija KhanKhadija Khan Nov 12, 2026 868 views

Question details

Create a formula that returns “yes” when the date in column A is within six months before or after the corresponding date in column B.

Excel IF and OR Formula for Dates Within Six Months
Product
Microsoft Excel spreadsheet formulas
Device & OS
not provided
Scenario
The user needs to compare two dates in the same row and identify dates that are no more than six calendar months apart.
Observed behavior
The desired result is “yes” if A1 is between six months before B1 and six months after B1; otherwise, the result should be blank.
Before you start

Make sure the values in columns A and B are real spreadsheet dates rather than text. Enter the formula in the result column for the first row, then fill it down for the remaining records.

Solution 1Recommended

Use IF, AND, and EDATE to test a six-month date range

Use this formula when you need a blank-or-yes result based on whether the date in A1 falls within six calendar months of the date in B1.

EDATE calculates dates a specified number of whole months before or after a reference date. The AND function confirms that A1 is on or after the date six months before B1 and on or before the date six months after B1.

1
Select the result cell

Click the cell where you want the result to appear, such as C1.

2
Enter the six-month comparison formula

Type or paste =IF(AND(A1>=EDATE(B1,-6),A1<=EDATE(B1,6)),"yes","") and press Enter.

3
Fill the formula down

Select C1 and drag the fill handle down, or double-click the fill handle, to apply the formula to additional rows.

4
Review blank results

A cell stays blank when the date in column A is earlier than EDATE(B1,-6) or later than EDATE(B1,6).

Use IF, AND, and EDATE to test a six-month date range
This checks calendar months: The formula uses six calendar months, not a fixed number of days. For example, EDATE handles months with different lengths automatically.
Work with dates in WPS Spreadsheets

Check six-month date ranges with WPS Spreadsheets

WPS Spreadsheets supports IF, AND, and EDATE formulas, so you can compare dates and return a clear result such as “yes” for records that fall within a six-month range.

  1. 1. Open the worksheet in WPS Spreadsheets: Launch WPS Office, choose Spreadsheets, and open the Excel workbook containing the dates.
  2. 2. Choose the output column: Click the first empty result cell, such as C1, next to the dates in columns A and B.
  3. 3. Enter the date-range formula: Enter =IF(AND(A1>=EDATE(B1,-6),A1<=EDATE(B1,6)),"yes","") and press Enter.
  4. 4. Apply the formula to all records: Drag the fill handle from the formula cell down the output column to calculate each row.
Use IF, AND, and EDATE to test dates within six calendar months.Fill formulas down quickly for large date lists.Open and edit Microsoft Excel .xlsx and .xls files with compatible spreadsheet formulas.Use a familiar spreadsheet interface for date calculations and reporting.
microsoft office alternative - wps office

Frequently Asked Questions

What does the EDATE function do in this formula?

EDATE returns a date a specified number of months before or after another date. EDATE(B1,-6) gives the date six months before B1, while EDATE(B1,6) gives the date six months after B1.

Why does the formula use AND instead of OR?

The date in A1 must meet both limits at the same time: it must be on or after the lower boundary and on or before the upper boundary. Using OR would return “yes” for almost every date.

How can I return “no” instead of a blank cell?

Replace the final empty string in the formula with “no”: =IF(AND(A1>=EDATE(B1,-6),A1<=EDATE(B1,6)),"yes","no").

How do I compare dates within six months in WPS Spreadsheets?

Click a result cell and enter =IF(AND(A1>=EDATE(B1,-6),A1<=EDATE(B1,6)),"yes",""). WPS Spreadsheets supports these functions in .xlsx and .xls workbooks.