To calculate tenure in Excel, use the DATEDIF function with the start date and end date, specifying the unit as “Y” for years, “M” for months, or “D” for days. For example, =DATEDIF(A2, B2, "Y") returns the number of full years between dates in A2 and B2. This article explains the formula in detail, how to combine years and months, handle leap years, and avoid common errors.
Why Calculate Tenure in Excel?
Tenure, also called length of service, is the duration an employee has worked for a company or how long an asset has been in use. HR teams use it for benefits eligibility, vesting schedules, and anniversary awards. Finance departments track tenure for depreciation or warranty periods. Because Excel stores dates as serial numbers (e.g., January 1, 1900 is 1), you can subtract dates directly, but that gives raw days, not human-friendly years and months. The DATEDIF function is the standard tool because it calculates complete calendar periods without rounding.
The Core Formula: DATEDIF
Assume your start date is in cell A2 and your end date is in B2. To get the number of full years:
=DATEDIF(A2, B2, "Y")– returns whole years.=DATEDIF(A2, B2, "YM")– returns remaining months after the last full year.=DATEDIF(A2, B2, "MD")– returns remaining days after the last full month.=DATEDIF(A2, B2, "M")– returns total months (e.g., 18 months for 1.5 years).=DATEDIF(A2, B2, "D")– returns total days.
For example, with A2 = 1/15/2020 and B2 = 7/20/2023, =DATEDIF(A2, B2, "Y") returns 3, =DATEDIF(A2, B2, "YM") returns 6, and =DATEDIF(A2, B2, "MD") returns 5. So tenure is 3 years, 6 months, and 5 days.
Combining Years, Months, and Days in One Cell
To display a readable text like “3 years, 6 months”, use the ampersand (&) to concatenate results. With the same cells:
=DATEDIF(A2, B2, "Y") & " years, " & DATEDIF(A2, B2, "YM") & " months"
This returns 3 years, 6 months. To include days, add another segment: & " days" after the MD result. If you want a numeric value like 3.5 years (for averaging), use =DATEDIF(A2, B2, "M")/12 which gives 42/12 = 3.5. Note that this assumes 12 months per year, which is standard for tenure calculations.
Using TODAY() for Ongoing Tenure
When calculating tenure up to the current date, use TODAY() as the end date. For example, =DATEDIF(A2, TODAY(), "Y") gives full years from the start date to today. This updates automatically each time the workbook recalculates. Be aware that TODAY() is volatile – it changes daily, so if you need a snapshot, replace it with a static date (e.g., 12/31/2024) or copy values.
Handling Leap Years and Edge Cases
DATEDIF handles leap years correctly because it counts calendar days, not 365-day years. For example, from Feb 29, 2020 to Feb 28, 2021, DATEDIF(..., "Y") returns 0 because a full year hasn’t passed (the anniversary is Feb 29, which doesn’t exist in 2021). Excel treats the end of February as the anniversary, so Feb 28 is considered the full year mark in non-leap years. If you need to count Feb 28 as a full year, use an alternative: =IF(AND(MONTH(A2)=2, DAY(A2)=29, MONTH(B2)=2, DAY(B2)=28), DATEDIF(A2, B2, "Y")+1, DATEDIF(A2, B2, "Y")) – but this is rarely needed.
Common Errors and How to Fix Them
- #NUM! error: Occurs when the start date is after the end date. Swap the dates or use
IFto check:=IF(A2>B2, "Start after end", DATEDIF(A2, B2, "Y")). - #VALUE! error: Happens if the dates are not real Excel dates (e.g., text). Use
DATEVALUEto convert text like “01/15/2020” to a date, or ensure cells are formatted as dates. - DATEDIF not showing in function list: DATEDIF is undocumented in some Excel versions, but it works. Type it manually; it’s not in the Insert Function dialog.
- Negative tenure: If you subtract dates directly (e.g.,
=B2-A2), you get a negative number if B2 is earlier. UseABSorMAXto avoid negatives.
Alternative Methods: YEARFRAC and INT
If you prefer a decimal year value, use YEARFRAC. With A2 and B2, =YEARFRAC(A2, B2) returns the fraction of a year between the dates, based on a 365-day year by default. For example, from 1/15/2020 to 7/20/2023, YEARFRAC returns approximately 3.51 (actual: 1282 days / 365 = 3.5123). To get whole years from YEARFRAC, use =INT(YEARFRAC(A2, B2)). This method is simpler but less precise for month/day breakdowns. Another approach is to subtract dates and divide by 365.25 to account for leap years: =INT((B2-A2)/365.25). This gives a close approximation but can be off by a day in some cases.
Frequently Asked Questions
How do I calculate tenure in years and months in Excel?
Use two DATEDIF formulas: one for years ("Y") and one for remaining months ("YM"). Concatenate them with text, as shown above. For example, =DATEDIF(A2, B2, "Y") & " years " & DATEDIF(A2, B2, "YM") & " months".
Can I calculate tenure in months only?
Yes, use =DATEDIF(A2, B2, "M") to get total months. For instance, from Jan 15, 2020 to Jul 20, 2023, the result is 42 months. This is useful for vesting schedules that require a certain number of months.
Why does DATEDIF give a #NUM! error?
The #NUM! error appears when the start date is later than the end date, or when the unit argument is invalid. Check that your start date is earlier, and that you’re using a valid unit like “Y”, “M”, “D”, “YM”, “YD”, or “MD”. Also ensure the dates are actual date values, not text.
How do I calculate tenure from hire date to today in Excel?
Use =DATEDIF(A2, TODAY(), "Y") for years, or combine with months as =DATEDIF(A2, TODAY(), "Y") & " years " & DATEDIF(A2, TODAY(), "YM") & " months". Remember that TODAY() updates daily, so the result changes each day the file is opened.
Is there a way to round tenure to the nearest whole year?
Yes, use =ROUND(YEARFRAC(A2, B2), 0) to round to the nearest year. For example, 3.5 years rounds to 4. If you need to round down, use INT or ROUNDDOWN. For standard tenure, rounding down is more common (e.g., 3.9 years counts as 3 years).
Does DATEDIF work in Google Sheets?
Yes, DATEDIF works in Google Sheets with the same syntax. However, in Google Sheets, the function is documented and appears in the autocomplete. The behavior is identical for most cases.
Related
- Computer Data Encryption: How It Works
- How to Make Random Numbers in Python
- Sitting Balance Test Calculator: How to Use It
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Contact List Excel Example and Setup GuideA useful contact list Excel example has one person per row and clear columns for name, phone, email,…
- Entry Level Data Entry in Pasadena TX: Jobs & PayEntry-level data entry jobs in Pasadena, TX, typically require a high school diploma or GED, basic computer skills…
- Customer List Format in Excel: Fields, Setup, and TipsA useful customer list in Excel has one row per customer and one column for each kind of…
- Professional Contact List Template Excel: Free Setup GuideYes— you can use a free professional contact list template in Excel or make one yourself in a…
- How to Delete Just One Cell in ExcelTo delete just one cell in Excel and move other cells into its place, select the cell, choose…
- How to Insert a Transition in PowerPoint and Customize ItTo insert a transition in PowerPoint, select the slide where the transition should appear, open the Transitions tab,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.