Function Problems

How to Use IF and EDATE to Compare Expiry Dates in Excel

Olivia MillerOlivia Miller Nov 10, 2026 869 views

Question details

The user needs a formula to compare an existing expiry date with a calculated date (e.g., 24 months after a start date) and return the appropriate date based on business rules.

How to Use IF and EDATE to Compare Expiry Dates in Excel
Product
Excel
Device & OS
not provided
Scenario
Managing expiry dates and ensuring they do not exceed a maximum allowed duration (like 24 months) from a manufacturing or starting date.
Observed behavior
The user requires a logical formula that returns a maximum of 24 months after the start date, or the actual expiry date if it occurs sooner.
Before you start

Ensure your date columns are formatted as 'Date' rather than 'Text' so the EDATE function calculates accurately, and identify the cells containing your starting date and current expiry date.

Solution 1Recommended

Using IF and EDATE to Cap Expiry Dates

Combine the IF and EDATE functions to enforce a maximum validity period, returning the earlier of the two dates.

The EDATE function calculates a date a specific number of months before or after a given start date. By nesting EDATE inside an IF function, you can evaluate whether the actual expiry date is greater than your maximum allowed timeframe (e.g., 24 months).

1
Select the target cell

Click on the cell where you want the final, calculated expiry date to appear.

2
Input the formula

Type =IF(H8>EDATE(B8,24),EDATE(B8,24),H8), assuming H8 is the current expiry date and B8 is the manufacturing or start date.

3
Press Enter and Format

Hit the Enter key to apply the formula. If the result appears as a large serial number, right-click the cell, select 'Format Cells', and apply a Date format.

4
Drag to fill

Click and drag the fill handle at the bottom-right corner of the cell to apply this formula to the rest of your data column.

Using IF and EDATE to Cap Expiry Dates
Date Value Formats: If your manufacturing date and expiry are stored as separate text values instead of valid dates, use the DATEVALUE function or combine them properly before running the IF and EDATE calculation.
Advanced Formula Support

Manage Complex Date Calculations in WPS Spreadsheet

WPS Spreadsheet fully supports advanced date and logical functions, including IF and EDATE, allowing you to easily handle complex business rules for expiry dates and timelines without any hassle.

  1. 1. Open your worksheet: Launch WPS Spreadsheet and open the document containing your dates.
  2. 2. Enter the IF and EDATE formula: Select an empty cell and input =IF(H8>EDATE(B8,24),EDATE(B8,24),H8) to cap the date.
  3. 3. Format the cells: Right-click the result, select 'Format Cells', and choose your preferred Date format.
  4. 4. Apply to all rows: Double-click the fill handle to apply the calculation to your entire dataset.
Fully compatible with Microsoft Excel formulas and functions.Includes a comprehensive formula library for date and time calculations.Built-in error checking for complex nested functions.Free to use with a familiar, easy-to-navigate interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my EDATE formula return a random number instead of a date?

In spreadsheet programs, dates are stored as sequential serial numbers. If your formula returns a number like 44927, simply select the cell, right-click, choose 'Format Cells', and change the category to 'Date'.

How do I subtract months using the EDATE function?

To calculate a date in the past, use a negative number for the months argument. For example, =EDATE(B8, -6) will return the date exactly 6 months before the date in cell B8.

Can I use the MIN function instead of IF and EDATE?

Yes, using the MIN function is a shorter alternative for this specific logic. You can use =MIN(H8, EDATE(B8, 24)) to return whichever date comes first, eliminating the need for the IF statement.

What if my start date cell is empty?

If the referenced start date cell (e.g., B8) is blank, EDATE will treat it as 0 (January 0, 1900). To avoid incorrect results, wrap your formula in another IF statement to check for blank cells, like =IF(ISBLANK(B8), "", MIN(H8, EDATE(B8, 24))).