Category: FUNCTION | Updated: 2026-11-22
YEARFRAC Function
YEARFRAC Function
The YEARFRAC function in Google Sheets returns the number of years (including fractional years as a decimal) between a start date and an end date. It is frequently used for calculating years of service, age, and prorated interest.
Syntax
=YEARFRAC(start_date, end_date, [day_count_convention])
- start_date: The start date of the period.
- end_date: The end date of the period.
- day_count_convention (optional): A number from
0to4specifying how days in a month and year are counted. Defaults to0if omitted.
Day Count Convention Options
| Code | Convention | Description |
|---|---|---|
0 (or omitted) |
US (NASD) 30/360 | Assumes 30 days per month and 360 days per year |
1 |
Actual / Actual | Uses actual calendar days and leap years (365 or 366 days) |
2 |
Actual / 360 | Divides actual elapsed days by a 360-day year |
3 |
Actual / 365 | Divides actual elapsed days by a fixed 365-day year |
4 |
European 30/360 | Assumes 30 days per month and 360 days per year using European rules |
Practical Examples with a Table
This example calculates employees’ years of service (both decimal and completed full years) from their hire date and a reference date.
| A (Employee Name) | B (Hire Date) | C (Reference Date) | D (Years of Service - Decimal) | E (Completed Years) | |
|---|---|---|---|---|---|
| 1 | Employee Name | Hire Date | Reference Date | Years of Service (Decimal) | Completed Years |
| 2 | Sato | 2021/04/01 | 2026/10/01 | =YEARFRAC(B2, C2, 1) |
=INT(D2) |
| 3 | Suzuki | 2025/05/25 | 2026/11/24 | =YEARFRAC(B3, C3, 1) |
=INT(D3) |
- Result in D2:
5.5(5 and a half years have elapsed, so5.5is returned) - Result in E2:
5(INTtruncates the decimal part to display 5 completed years) - Result in D3:
1.5(Approximately 1.5 years have elapsed, so1.5is returned)
Common Errors and Precautions
- When
#NUM!errors occur:- Occurs if
day_count_conventionis set to a number outside0–4(such as5or-1).
- Occurs if
- When
#VALUE!errors occur:- Occurs if
start_dateorend_datecontains a value that cannot be recognized as a date.
- Occurs if
- Watch out for minor rounding differences on birthdays:
- Even when using convention
1(Actual/actual), leap years can sometimes cause a tiny discrepancy on the exact birthday (such as19.999...). For strict age calculations, consider usingDATEDIF(birth_date, reference_date, "Y")as well.
- Even when using convention
Frequently Asked Questions
Q. Can I use YEARFRAC to calculate completed age or years of service?
A. Yes. By rounding down the decimal years returned by YEARFRAC using INT or ROUNDDOWN, you can calculate accurate completed age or years of service while accounting for leap years (e.g., =INT(YEARFRAC(birth_date, TODAY(), 1))).
Q. Which option is most commonly used for the third argument 'day_count_convention'?
A. For age calculations or accurate proportions based on actual calendar days, '1 (Actual/actual)' is the most commonly used convention.