
How to Calculate Age in Excel: DATEDIF, YEARFRAC and the /365 Trap
To calculate age in Excel, use =DATEDIF(A2,TODAY(),"Y"), which counts complete years. Dividing the days by 365 looks fine and gives the wrong age for about 2.7% of dates in a test of 19,836. Here are the formulas for years, months, days, age on a given date and decimal age.
Tech Talk News Editorial
9 min read
Key takeaways
- The formula =DATEDIF(A2,TODAY(),"Y") returns age in complete years, and swapping TODAY() for another date or cell gives the age on that date; Microsoft warns that DATEDIF may calculate incorrect results under certain scenarios.
- Dividing the days since birth by 365 fails because leap days accumulate: for a birthday of 06/15/1990 checked on 06/14/2026, the 13,148 days divide to 36.02 and round down to 36 when the real age is 35.
- In a test of 19,836 random birth and as-of date pairs, dividing by 365 gave the wrong age 545 times (2.7%), while dividing by 365.25 was wrong 19 times (0.1%), so neither beats DATEDIF for whole years.
- Microsoft says the DATEDIF "MD" unit may return a negative number, zero or an inaccurate result, so get leftover days with =TODAY()-EDATE(A2,DATEDIF(A2,TODAY(),"M")) instead.
- DATEDIF returns #NUM! when the start date is later than the end date, and YEARFRAC returns a decimal age, such as about 36.5, that is not meant for a "how old are you" answer.
On this page9 sections
To calculate age in Excel, put the birth date in a cell and use =DATEDIF(A2,TODAY(),"Y"). The “Y” unit returns complete years between the two dates, and TODAY() makes the answer roll forward every day.[1] For the age on any other date, swap TODAY() for that date.
Most pages on this stop there, or recommend dividing the days by 365. That second one is wrong often enough to matter, and I measured how often below. I checked the function details against Microsoft Support's pages on November 29, 2026.
The formula, step by step
- Type the birth date in A2 as a real date, for example 06/15/1990.
- In B2, type
=DATEDIF(A2,TODAY(),"Y")and press Enter. - Fill the formula down the column for everyone else.
DATEDIF takes DATEDIF(start_date, end_date, unit). The start date must come first, and Microsoft's example =DATEDIF(Start_date,End_date,"Y") turns 1/1/2001 to 1/1/2003 into 2.[1] If the start date is later than the end date, you get #NUM!.[1]
Guard blank rows with =IF(A2="","",DATEDIF(A2,TODAY(),"Y")), so an empty birth date doesn't show a nonsense age.
The units DATEDIF understands
| Unit | What it returns | Use it for age? |
|---|---|---|
"Y" | Complete years in the period | Yes, this is age |
"M" | Complete months in the period | Yes, for age in months |
"D" | Days in the period | Yes, for age in days |
"YM" | Months, ignoring days and years | Yes, the months part |
"YD" | Days, ignoring years | Rarely |
"MD" | Days, ignoring months and years | No, Microsoft advises against it |
Table source: Microsoft Support.[1] The last column is my judgment.
Heads up
Age in years, months and days
Take someone born on 06/15/1990, and ask for the age on 11/29/2026. The answer should be 36 years, 5 months and 14 days. Years and months are straightforward:
=DATEDIF(A2,TODAY(),"Y")gives 36.=DATEDIF(A2,TODAY(),"YM")gives 5, the months since the last birthday.
Days are where the usual tutorial reaches for "MD". Don't. Count from the last full month instead:
=TODAY()-EDATE(A2,DATEDIF(A2,TODAY(),"M"))
DATEDIF with “M” counts 437 complete months, EDATE moves the birth date forward by exactly 437 months to 11/15/2026, and subtracting leaves 14 days.
EDATE is a documented function on Microsoft's age page, where =EDATE(A3,-4) returns the date four months earlier.[2] This pairing is my own construction rather than a Microsoft formula, so test it on a few birthdays you know.
Join all three into one cell with the ampersand:
=DATEDIF(A2,TODAY(),"Y")&" years, "&DATEDIF(A2,TODAY(),"YM")&" months, "&(TODAY()-EDATE(A2,DATEDIF(A2,TODAY(),"M")))&" days"
How that string is built is covered in the concatenate guide.
Age on a specific date
Age on a given date means changing the end date. Type the date into the formula, or keep it in a cell:
=DATEDIF(A2,DATE(2026,12,31),"Y")returns the age on December 31, 2026.=DATEDIF(A2,B2,"Y")returns the age on whatever date sits in B2.
That is how you answer “how old will they be on the first day of school” or “how old were they at the time of the event.” A minor-or-adult check is one more step: =IF(DATEDIF(A2,TODAY(),"Y")>=18,"Adult","Minor").
Why days divided by 365 is wrong
The tempting formula is =INT((TODAY()-A2)/365). A year is 365 days, so what could go wrong? Leap days. Every four years the calendar adds a day, and the division doesn't know it.
Here is a case you can check on a calculator. Take the 06/15/1990 birth date, and ask on 06/14/2026, the day before the 36th birthday. The person has lived 13,148 days. Divide by 365 and you get 36.02, which INT rounds down to 36. The real age is 35.
Nine leap days, 1992 through 2024, are the difference.
So how often does this go wrong? I ran a script over 19,836 random pairs of birth date and as-of date, with birth dates from 1940 through 2022 and as-of dates from the past eight years, and compared each result with the true age by calendar.
Dividing by 365 was wrong 545 times, or 2.7%. Dividing by 365.25, which Microsoft's age page uses to get 12.08 for a decimal age, was wrong 19 times, or 0.1%.[2] That's a good decimal estimate and still not an age you'd put on a form.
The other classic, =YEAR(NOW())-YEAR(A2), appears on the same Microsoft page.[2] It subtracts the years and ignores the birthday, so it is a year too high for everyone whose birthday hasn't happened yet. That's fine for a rough cohort count and wrong for a person.
Takeaway
A year isn't 365 days, and a person's age isn't a division. Use DATEDIF with “Y” for whole years, and keep the decimal tricks for statistics.
YEARFRAC: decimal age
YEARFRAC returns the fraction of a year between two dates, with the syntax YEARFRAC(start_date, end_date, [basis]).[3] Basis 1 uses the actual number of days, so =YEARFRAC(A2,TODAY(),1) returns about 36.5 for our example.
If basis is omitted it uses the US 30/360 method, and Microsoft notes that method may return an incorrect result when the start date is the last day of February.[3]
I use YEARFRAC for things like tenure and pro-rated amounts, where 36.5 is what I want. For a person's age, whole years from DATEDIF is the answer people expect.
If it doesn't work
- #NUM!. The start date is later than the end date.[1] Swap them or fix a typo in the year.
- #VALUE! or a wrong age. The birth date may be text, not a real date. Microsoft warns that text dates can cause problems, and recommends entering dates with the DATE function.[3]
- Dates before 1900. Excel's serial numbers start with January 1, 1900 as 1, so an earlier date is not a date to Excel.[3]
- The age never changes. You typed today's date instead of TODAY(). Use the function so the value updates.
- Months or days look off. You're probably using the “MD” unit. Switch to the EDATE version above.
My rule
Whole years: DATEDIF with “Y”. Years, months and days: DATEDIF plus EDATE, never “MD”. Fractions: YEARFRAC. And never divide by 365. If you count people in age bands, pair the age column with the SUMIFS guide for the totals.
Primary sources
- 1.PrimaryMicrosoft Support, "DATEDIF function". Syntax, the unit codes, the Lotus 1-2-3 warning, the "MD" unit problem, the Y example and the #NUM! error.
- 2.PrimaryMicrosoft Support, "Calculate age". The YEAR(NOW()) subtraction, YEARFRAC, the 365.25 formula that returns 12.08, and EDATE.
- 3.PrimaryMicrosoft Support, "YEARFRAC function". Syntax, the basis table, the February 30/360 note, text dates, and serial numbers starting at January 1, 1900.
Frequently asked questions
6 questions
What is the formula to calculate age in Excel?
Use =DATEDIF(A2,TODAY(),"Y"), where A2 holds the birth date. The "Y" unit returns complete years between the two dates, and TODAY() makes the age update each day. To get the age on another date, replace TODAY() with that date or a cell that holds it.
How do I calculate age in years, months and days in Excel?
Join three results: =DATEDIF(A2,TODAY(),"Y")&" years, "&DATEDIF(A2,TODAY(),"YM")&" months, "&(TODAY()-EDATE(A2,DATEDIF(A2,TODAY(),"M")))&" days". The "YM" unit gives months ignoring years, and the EDATE part finds days since the last full month. Microsoft says to avoid the "MD" unit.
How do I calculate age on a specific date in Excel?
Replace TODAY() with the date. For a date typed into the formula, use =DATEDIF(A2,DATE(2026,12,31),"Y"). For a date stored in B2, use =DATEDIF(A2,B2,"Y"). The start date must come first or Excel returns #NUM!.
Why is dividing by 365 wrong for calculating age?
Leap days make a year 365.25 days on average, so dividing by 365 pushes the age up by a few days. A person born on 06/15/1990 has lived 13,148 days on 06/14/2026, which divides to 36.02 and rounds down to 36, but they are still 35.
Is DATEDIF still supported in Excel?
Yes, it works in current Excel, but Microsoft documents it only as a function provided to support older Lotus 1-2-3 workbooks. Its page warns that DATEDIF may calculate incorrect results under certain scenarios, and recommends against the "MD" unit.
What does #NUM! mean in an Excel age formula?
It means the start date is later than the end date. DATEDIF returns #NUM! in that case. Check that the birth date is in the first argument and that nobody typed a future birth date.
Keep reading
Written by
Tech Talk News Editorial
Computer engineering background. Writes about software, AI, markets, and real estate, and the places where the three meet.
About Tech Talk News

