logo
search
Function Problems

How to Use an Excel Formula to Return Yes or No for Over 18 and Over 21 Ages

Maira MehtabMaira Mehtab Sep 20, 2026 869 views

Question details

The user needs to compare a date of birth against the current date to determine if a person is over 18 or over 21, outputting a 'Yes' or 'No' text string.

Product
Excel
Device & OS
not provided
Scenario
Filtering or evaluating eligibility based on age thresholds (like 18 or 21) using birth dates imported from Microsoft Forms or entered manually.
Observed behavior
Return the exact string 'Yes' if the calculated age meets or exceeds the specified threshold, and 'No' otherwise.
Before you start

Ensure that your Date of Birth column is formatted as actual Dates in Excel, especially if the data was imported from external sources like Microsoft Forms or Power Automate.

Solution 1Recommended

Use IF and DATEDIF Functions for Exact Age Calculation

The DATEDIF function accurately calculates the elapsed years between the date of birth and today, which is the most reliable method for calendar-accurate age comparisons.

This method avoids issues with leap years by calculating exact full years elapsed.

1
Select the target cell

Click on the cell where you want the 'Yes' or 'No' result to appear (e.g., cell B2).

2
Enter the Over 18 formula

Assuming the Date of Birth is in cell A2, type the following formula: =IF(DATEDIF(A2,TODAY(),"Y")>=18,"Yes","No") and press Enter.

3
Modify for Over 21

If you are checking for an age of 21, adjust the threshold in the formula to: =IF(DATEDIF(A2,TODAY(),"Y")>=21,"Yes","No").

Tip: You can double-click the small square at the bottom-right corner of the cell to quickly apply this formula to the entire column.
WPS Spreadsheet Solution

Calculate Ages and Manage Formulas Seamlessly in WPS Spreadsheet

You can effortlessly build age calculation formulas like IF, DATEDIF, and EDATE using WPS Spreadsheet. It offers full compatibility with standard spreadsheet syntax, ensuring imported forms evaluate correctly.

  1. 1. Open your data in WPS Spreadsheet: Launch WPS Office and open your spreadsheet containing the dates of birth.
  2. 2. Select your output cell: Click on the cell adjacent to the first date of birth where the eligibility status will go.
  3. 3. Insert the DATEDIF formula: Type =IF(DATEDIF(A2,TODAY(),"Y")>=18,"Yes","No") and press Enter on your keyboard.
  4. 4. Auto-fill the column: Drag the fill handle down to apply the Yes/No logic to all other entries in your list.
100% compatible with Microsoft Excel formula syntax and structural references.Lightweight, fast-loading application suitable for processing large datasets.Intuitive format tools to easily convert imported text strings into valid dates.Completely free to use for daily spreadsheet formula tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my formula return a #NUM! error?

The DATEDIF function returns a #NUM! error if the date in the starting cell (Date of Birth) is greater than the ending date (Today). Check your dataset to ensure there are no future dates or invalid entries.

Can I use an approximate calculation like 18 * 365.25?

Yes, you can use =IF(TODAY()-A2>=18*365.25,"Yes","No"). However, this is an approximation and might be off by a day during certain leap year cycles. The DATEDIF or EDATE methods are highly recommended for strict legal or calendar accuracy.

Why is the formula returning 'No' for everyone regardless of their age?

This usually happens if Excel doesn't recognize your imported dates as actual dates, treating them as text instead. You can fix this by selecting your dates column, going to the Data tab, and using the 'Text to Columns' tool to convert them.

How do I add a third option for ages between 18 and 21?

You can nest multiple IF statements. For example: =IF(DATEDIF(A2,TODAY(),"Y")>=21,"Over 21", IF(DATEDIF(A2,TODAY(),"Y")>=18,"Over 18","Under 18")).