Function Problems

Excel Formula to Check Whether a Date Is Within Six Months

Maira MehtabMaira Mehtab Nov 20, 2026 871 views

Question details

Compare a transaction date with a reference date and classify it as before, after, or within a six-month range.

Check Whether a Date Is Within Six Months in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user wants to compare sales transaction dates with a reference date, which may be in another workbook.
Observed behavior
The desired result is Before, After, or Within range, based on either calendar months or an approximate number of days.
Before you start

Make sure the transaction and reference cells contain valid Excel dates rather than text. Decide whether the range means six calendar months or exactly 182 days, and whether the boundary dates should count as within range.

Solution 1Recommended

Compare dates using six calendar months

Use EDATE when the range should extend six calendar months on either side of the reference date.

1
Enter the dates

Place the transaction date in A2 and the reference date in B2, or identify the cells that contain them.

2
Enter the formula

Select C2 and enter =IF(A2<EDATE(B2,-6),"Before",IF(A2>EDATE(B2,6),"After","Within range"))

3
Apply it to other rows

Press Enter, then drag the fill handle from C2 down to compare additional rows. Replace B2 with $B$2 before filling if every row uses the same reference date.

Compare dates using six calendar months
Boundary dates: Dates exactly six calendar months before or after the reference date return Within range. EDATE uses the last day of the target month if the original day does not exist in that month.
Compare dates in WPS Spreadsheets

Check a six-month date range in WPS Spreadsheets

Use the EDATE and IF functions in WPS Spreadsheets to compare transaction dates with a reference date and label the results.

  1. 1. Open the spreadsheet: Open WPS Spreadsheets and use Open to select your Excel workbook, or create a new spreadsheet.
  2. 2. Add the dates: Enter a transaction date in A2 and a reference date in B2.
  3. 3. Calculate the result: Select C2, enter =IF(A2<EDATE(B2,-6),"Before",IF(A2>EDATE(B2,6),"After","Within range")), and press Enter.
  4. 4. Apply the formula: Drag the fill handle from C2 down to compare more rows. Use $B$2 in the formula if the reference date stays in B2.
Compare dates using calendar months or a fixed 182-day range.Open and edit Microsoft Excel XLSX and XLS files.Fill the formula down to classify multiple transactions.
microsoft office alternative - wps office

Frequently Asked Questions

Do dates exactly six months away count as within range?

Yes. The calendar-month formula uses < and >, so dates equal to EDATE(B2,-6) or EDATE(B2,6) return Within range. Use <= and >= instead if those boundary dates should return Before and After.

Can the reference date be in another workbook?

Yes. Open both workbooks, start the formula in the transaction workbook, and select the reference date cell in the other workbook when entering the reference. Excel will insert an external workbook reference.

Why does 182 days give a different result from six months?

Calendar months have different lengths, so six months is not always 182 days. Use EDATE for calendar months or add and subtract 182 for a fixed-day range.

What if Excel does not recognize my dates?

Check whether the cells contain date values rather than text. Select a cell and use Home > Number Format to inspect its format; if necessary, re-enter the date in a format Excel recognizes.