Excel Formula to Check Whether a Date Is Within Six Months
Question details
Compare a transaction date with a reference date and classify it as before, after, or within a six-month range.

- 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.
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.
Compare dates using six calendar months
Use EDATE when the range should extend six calendar months on either side of the reference date.
Place the transaction date in A2 and the reference date in B2, or identify the cells that contain them.
Select C2 and enter =IF(A2<EDATE(B2,-6),"Before",IF(A2>EDATE(B2,6),"After","Within range"))
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 a 182-day range
Use a day-based formula when the intended range is exactly 182 days on either side of the reference date.
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. Open the spreadsheet: Open WPS Spreadsheets and use Open to select your Excel workbook, or create a new spreadsheet.
- 2. Add the dates: Enter a transaction date in A2 and a reference date in B2.
- 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. 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.

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.




