DOB (Age from Date of Birth)
Calculate age from date of birth in Excel and Sheets using DATEDIF. Get exact age in years, months, and days with accurate, error-free formulas.
=DATEDIF(date_of_birth, TODAY(), "Y")Quick Answer
DOB calculation DOB calculation calculates age from date of birth in Excel and Google Sheets. It returns years (or months/days) for HR records, patient databases, and age verification.
=DATEDIF(A2, TODAY(), "Y")Practical Examples
Basic Age Calculation in Years
Calculate employee age in complete years from birth date
Exact Age in Years, Months, and Days
Display precise age breakdown for medical records
Age Calculation as of Specific Date
Calculate age on hire date for historical records
Age in Months Only
Track infant ages in months for developmental milestones
Age with Error Handling
Prevent errors when birth date is missing or invalid
Age Calculation with YEARFRAC (Decimal Age)
Calculate precise fractional age for financial calculations
Common Errors and Solutions
A value used in the formula is of the wrong data type
The birth date cell contains text instead of an actual date value, or the date format is not recognized by Excel/Sheets. Common culprits include dates entered as text like "January 15, 1990" or dates in non-standard formats.
1. Check if the birth date is stored as text by selecting the cell and looking at the formula bar 2. Convert text to date using DATEVALUE function: =DATEVALUE("1/15/1990") 3. Use Data > Text to Columns with Date format to convert entire column 4. Ensure dates are entered in mm/dd/yyyy or dd/mm/yyyy format depending on regional settings 5. Format the cell as Date using Format > Cells > Date
Always format DOB columns as Date format before entering data. Use data validation to restrict entries to date format only. Test your formula with a known date first.
Example:
Formula cannot calculate due to invalid date range
The birth date is AFTER today's date (future date), or the start_date is after end_date in DATEDIF. This error also occurs when dates are extremely far in the past or future, exceeding Excel's date range (1900-9999).
1. Verify the birth date is in the past, not the future 2. Check for typos in year entry (2024 instead of 1924) 3. Ensure the date order is correct: DATEDIF(earlier_date, later_date, unit) 4. Add validation: =IF(B2>TODAY(), "Future Date", DATEDIF(B2, TODAY(), "Y")) 5. Use absolute date references to avoid calculation errors
Implement data validation rules: =B2<TODAY() to prevent future dates. Add visual indicators (conditional formatting) for suspicious ages (e.g., >150 years or <0 years).
Example:
Excel doesn't recognize the function name DATEDIF
While DATEDIF works in Excel and Google Sheets, it's an undocumented function and won't appear in autocomplete. The error typically occurs from typos in the function name or incorrect syntax.
1. Double-check spelling: DATEDIF (not DATEIF, DATE_DIF, or DATDIF) 2. Ensure all parameters are correct: DATEDIF(start, end, "unit") 3. Use quotation marks around the unit parameter: "Y" not Y 4. If DATEDIF doesn't work, use alternative: =INT(YEARFRAC(B2, TODAY(), 1)) 5. Try =YEAR(TODAY())-YEAR(B2) as a simple alternative
Test DATEDIF in a blank cell first. Copy working formulas rather than retyping. Use Excel's Formula Builder for syntax help.
Example:
Formula calculates age incorrectly, often off by 1 year
Using simple arithmetic like =(TODAY()-B2)/365 doesn't account for leap years properly. Dividing by 365 gives slightly wrong results over time. Also occurs when using YEAR(TODAY())-YEAR(B2) which ignores months and days.
1. Switch to DATEDIF for accurate complete years: =DATEDIF(B2, TODAY(), "Y") 2. Avoid =YEAR(TODAY())-YEAR(B2) as it ignores whether birthday has occurred 3. Use =INT(YEARFRAC(B2, TODAY(), 1)) for decimal precision 4. Don't divide by 365.25; use DATEDIF instead 5. Test with known birthdates to verify accuracy
Always use DATEDIF or YEARFRAC for age calculations instead of arithmetic operations. These functions properly handle leap years, month lengths, and incomplete years.
Example:
Age displays as negative number or impossibly high (125+ years)
Empty DOB cell defaults to Excel's zero date (1/1/1900), creating an age of 125+ years. Negative ages occur when start_date and end_date are reversed in DATEDIF formula.
1. Check for blank DOB cells: =IF(ISBLANK(B2), "", DATEDIF(B2, TODAY(), "Y")) 2. Add age validation: =IF(DATEDIF(B2,TODAY(),"Y")>100, "Verify DOB", DATEDIF(B2,TODAY(),"Y")) 3. Ensure correct parameter order: DATEDIF(birth_date, current_date, "Y") 4. Use error handling: =IFERROR(DATEDIF(B2, TODAY(), "Y"), "") 5. Format column to show "" for zero values
Make DOB field required (data validation). Use conditional formatting to highlight ages >100 or <0 for review. Implement =IF(B2="", "", DATEDIF(B2, TODAY(), "Y")) wrapper.
Example:
Best Practices and Pro Tips
Always Use DATEDIF for Age in Years
DATEDIF is the most accurate method for calculating complete years of age. Unlike simple arithmetic (TODAY()-DOB)/365, DATEDIF correctly handles leap years and varying month lengths. It returns exactly the number of birthdays a person has had, which is the legal and commonly accepted definition of age.
Combine Multiple DATEDIF for Exact Age
For precise age breakdowns in years, months, and days, chain three DATEDIF functions with different unit parameters. Use "Y" for complete years, "YM" for remaining months after years, and "MD" for remaining days after months. This provides exact age calculations essential for pediatric medicine and legal applications.
Use IF to Hide Zero Values
When displaying age in years and months, zero values look unprofessional ("0 Years, 3 Months"). Wrap each DATEDIF component in an IF statement to hide zeros: IF(DATEDIF(...)=0,"",DATEDIF(...)&" Years, "). This creates cleaner displays like "3 Months" instead of "0 Years, 3 Months" for infants.
Implement Comprehensive Error Handling
Production spreadsheets must handle edge cases: blank cells, future dates, text entries, and invalid dates. Use IFERROR as outer wrapper, then IF(ISBLANK()) to check for empty cells, and IF(DOB>TODAY()) to catch future dates. This prevents error messages from appearing and guides users to correct data entry.
Avoid Simple Arithmetic Division
Never use formulas like (TODAY()-DOB)/365 or /365.25 for age calculations. These methods don't account for actual calendar dates and will produce incorrect results. For someone born on Feb 29, these formulas give wrong ages in non-leap years. Always use DATEDIF or YEARFRAC for accurate date calculations.
Use YEARFRAC for Decimal Ages
When you need fractional years (e.g., 25.5 years for actuarial calculations), use YEARFRAC with basis 1 (actual/actual). Wrap in ROUNDDOWN to control decimal places: ROUNDDOWN(YEARFRAC(DOB,TODAY(),1),2). This provides precise age including fractions, useful for insurance premiums and financial planning.
Calculate Age at Specific Date
Replace TODAY() with any date reference to calculate age as of that date. This is crucial for historical records, retirement calculations at specific retirement date, or determining age at hire. Use: DATEDIF(birth_date, specific_date_cell, "Y"). Perfect for "age at hire", "age at retirement", or "age on policy start date".
Format DOB Columns as Date Format
Before entering birth dates, format the entire column as Date format (Ctrl+1 > Date). This prevents Excel from misinterpreting entries. When dates are formatted as text (common when copying from other sources), DATEDIF returns #VALUE! error. Use TEXT() or DATEVALUE() functions to convert text dates before calculation.
DATEDIF Won't Appear in Autocomplete
DATEDIF is an undocumented legacy function in Excel, so it won't show up in function autocomplete or help files. However, it works perfectly in both Excel (all versions) and Google Sheets. Type it manually: =DATEDIF( and Excel will recognize it. Consider creating a formula template or using cell comments to document the formula for other users.
Add Data Validation to Prevent Future Dates
Prevent user errors by setting data validation on DOB columns. Set validation criteria to: Date less than or equal to =TODAY(). This stops users from accidentally entering future dates. Add a custom error message: "Birth date cannot be in the future." This proactive approach eliminates the #NUM! error before it occurs.
Use Conditional Formatting to Highlight Anomalies
Set up conditional formatting to automatically flag suspicious ages: color cells red if age > 100 years or < 0 years. Use formula: =OR(DATEDIF($A2,TODAY(),"Y")>100, DATEDIF($A2,TODAY(),"Y")<0). This visual system catches data entry errors immediately, such as typos in year (1924 vs 2024) or impossible dates.
Consider Regional Date Format Differences
Excel interprets dates differently based on regional settings: US uses MM/DD/YYYY, most other regions use DD/MM/YYYY. When sharing files internationally, use unambiguous date formats like 15-Jan-1990 or enter dates with DATE(year, month, day) function: DATE(1990, 1, 15). This prevents misinterpretation when 01/05/1990 could mean Jan 5 or May 1.
Need Help with DOB (Age from Date of Birth)?
Stop struggling with formula syntax. Use AskFormulas to generate validated formulas instantly with our AI-powered tool.
Example Excel formula:
Related Formulas
Master the DATE function in Excel to create dates from year, month, and day values. Learn syntax, examples, errors, and best practices.
Master the DATEDIF function to calculate date differences in years, months, or days. Learn syntax, examples, and solutions to common errors.
Master the TODAY function to insert dynamic current dates that update automatically. Learn practical examples and avoid common errors.
Master the YEAR function to extract years from dates in Excel and Google Sheets. Learn syntax, examples, error fixes, and best practices for date analysis.