Calculating the Number of Years Between Two Dates in Excel
To calculate the number of years between two dates in Excel, you can use either the YEARFRAC or DATEDIF function. Both functions are useful, and you need to understand their arguments before using them. Here’s an example where you have a start date in cell A1 and an end date in cell B1.
Using DATEDIF Function
DATEDIF is the easiest way to get the count of years between two dates. Note that DATEDIF is not in Excel’s function list, and you need to know its arguments before you use it.
To use DATEDIF to get the number of years between two dates, follow these steps:
- Enter the DATEDIF function in cell C1.
- Refer to cell A1, where you have the start date.
- Refer to cell B1, where you have the end date.
- In the third argument, enter the unit “y” to get the count of years.
- Hit enter to get the result.
=DATEDIF(A1, B1, “y”)
The result in cell C1 is the number of complete years between the two dates. If you want to get the months and days along with the year, you can use the formula in the following way:
=DATEDIF(A1,B1,”y”)&”y, “&DATEDIF(A1,B1,”ym”)&”m, “&DATEDIF(A1,B1,”md”)&”d”
Here, we used DATEDIF three times in the same formula but with different units.
Using YEARFRAC Function
If you don’t want to use the DATEDIF function, you can switch to YEARFRAC. Here’s an example where we have used the same start and end dates as in the DATEDIF example:
- Enter the YEARFRAC function in cell C1.
- In the first argument, refer to cell A1, where you have the start date.
- In the second argument, refer to cell B1, where you have the end date.
- Hit enter to get the result.
=YEARFRAC(A1,B1)
The result in cell C1 is the number of years between the two dates, including any fraction of a year. For example, if there are six months between two dates, the result will be 0.5. Note that YEARFRAC has a third argument that you can use to change the basis of difference that you want to use to get the years to count between two dates.
Both functions are useful in different situations, so choose the one that best fits your needs.