To find the years between two dates in Excel, subtract the earlier date from the later one and divide by 365.25, or use the DATEDIF function, which returns only whole years. For example, if A2 holds a start date and B2 an end date, =DATEDIF(A2,B2,"y") gives completed years, while =(B2-A2)/365.25 gives a decimal figure including the fraction of a year. The best choice depends on whether you want a full-year count (like an age) or a precise decimal (like a service length). All three approaches below work in Excel for Windows, Mac, and Excel for the web; labels on ribbon tabs can differ slightly between versions and regions, but the functions themselves are identical everywhere.
What You'll Need
- A spreadsheet in Excel (desktop or web) with two date columns, or two cells you can type dates into.
- Dates entered as real dates, not text. Excel recognises formats like 15/03/2019 or 2019-03-15 depending on your regional settings.
- Basic familiarity with typing a formula into a cell and pressing Enter.
Step-by-Step
- Lay out your data. Put the start date in one column (say A) and the end date in the next (say B), starting in row 2 so row 1 can hold headings. Type dates the way your region expects them; if Excel right-aligns the entry, it has read it as a real date. If it left-aligns, it treated it as text and the formulas below will fail.
- Check the dates are real. Click a date cell and look at the formula bar. It should show the date, not an apostrophe or extra spaces. If it looks like text, retype it without any leading apostrophe, or remove the stray spaces with
=TRIM(). - Enter the DATEDIF formula for whole years. In C2, type
=DATEDIF(A2,B2,"y")and press Enter. This returns the number of completed years between the dates, ignoring leftover months and days. Someone born on 20 June 1990 measured to 19 June 2026 returns 35; on 20 June 2026 it flips to 36. - Enter the decimal formula as a comparison. In D2, type
=(B2-A2)/365.25. This gives the exact span as a decimal, using 365.25 to account for leap years on average. Format the cell as a Number with two decimal places via the Home tab's number format dropdown. - Or use YEARFRAC for a built-in decimal. In E2, type
=YEARFRAC(A2,B2,1). The third argument is the day-count basis; 1 means actual days over actual year length, which is the most accurate for calendar spans. Omit the third argument and Excel uses a 30/360 convention that suits some financial calculations but not general date maths. - Fill the formulas down. Select C2:E2, grab the small square at the bottom-right corner of the selection, and drag down to the last row. Double-clicking the fill handle also copies the formulas to the bottom of the adjacent data.
- Build a text version if you want readable output. To show something like "35 years" in one cell, use
=DATEDIF(A2,B2,"y")&" years". The ampersand joins the number to text. Note this creates a text string, not a number, so you cannot sum or average it later without parsing it back. - Split out years and months when you need detail.
=DATEDIF(A2,B2,"y")&" y "&DATEDIF(A2,B2,"ym")&" m"gives a combined figure such as "35 y 4 m". The "ym" argument returns the leftover months after whole years are removed. - Set the result as a number, not a date. If a formula result shows a strange date such as 1/30/1900, the cell inherited a date format. Right-click the cell, choose Format Cells, and pick Number or General. This is the single most common cosmetic failure with date subtraction.
- Sanity-check a few rows by hand. Pick two rows and count the years yourself. A quick verification catches flipped date order, text-format dates, and basis arguments before the sheet is shared.
Common Mistakes
Subtracting the dates in the wrong order. Excel gives a negative number if the start date is later than the end date, and DATEDIF returns a #NUM! error instead of a negative. Wrap the formula in =ABS() if order cannot be controlled, or sort and fix the data.
Using 365 instead of 365.25. Dividing by 365 drifts by about a day every four years, so long spans come out slightly high. The 365.25 figure corrects for the average leap year but is still not exact for a specific pair of dates; YEARFRAC with basis 1 is.
Assuming DATEDIF appears in the function list. Excel's autocomplete does not suggest DATEDIF, though the function works when typed. That is because it is a legacy compatibility function, not because it is unsupported. Type it in full.
Filling formulas down when dates are text. If the source dates are text, every row returns #VALUE!. Fix the source column first, then the formulas recalculate correctly.
Confusing DATEDIF's "y" with a rounded decimal. DATEDIF truncates to completed years; it never rounds up. A span of 364 days returns 0 years, not 1. If you want rounding, wrap a decimal formula in =ROUND() deliberately.
Tips
Use a fixed reference date instead of TODAY() when you need reproducible results. Typing a date into one cell and referencing it with absolute addressing (for example $F$1) means every row measures against the same point, and the numbers do not change each time the sheet recalculates.
For ages, DATEDIF with "y" is the standard approach because it matches how people count birthdays. For service length, lease terms, or warranty periods, many organisations prefer YEARFRAC because decimals are easier to compare and report.
Convert the decimal to whole months by multiplying by 12 if months are the real reporting unit: =ROUND((B2-A2)/365.25*12,0). This avoids the awkward "3.98 years" style output.
Keep the source dates in one format across the sheet. Mixed day-first and month-first entries are a frequent cause of dates silently swapping day and month, which shifts results by months and is hard to spot. Set the column's format deliberately rather than relying on automatic entry.
Troubleshooting
The formula shows #VALUE!. One or both cells contain text rather than a date. Check the alignment: real dates right-align by default. Retype the cell without an apostrophe and remove any trailing spaces.
You see #NUM!. With DATEDIF, this almost always means the start date is after the end date. Swap the arguments or correct the data.
The result is a date like 1/30/1900. The cell is formatted as a date. Change the format to Number or General via Format Cells.
You get a negative number. The subtraction formula ran with reversed dates. Reorder, or use ABS, but confirm which row is genuinely wrong before applying a blanket fix.
The copied formula shows the same value in every row. Absolute references crept in. Remove the dollar signs from A2 and B2 so each row points at its own cells.
Frequently Asked Questions
Why doesn't DATEDIF show up in Excel's function suggestions?
It is kept for compatibility with older spreadsheets, so autocomplete skips it. Type it manually and it works normally.
What is the difference between DATEDIF "y" and YEARFRAC?
DATEDIF returns whole completed years and discards the remainder; YEARFRAC returns a decimal including the fraction of the year.
How do I count years since a date that updates automatically?
Use =DATEDIF(A2,TODAY(),"y"). The result recalculates whenever the workbook opens.
Can I get years and months together in one cell?
Yes, by combining two DATEDIF calls with the ampersand, using "y" and "ym" as the arguments.
Do these formulas work in Google Sheets and Excel online?
DATEDIF and YEARFRAC both work in Google Sheets and in Excel for the web. Cell formatting steps follow the same menu names in the web version.