# YEARFRAC function in Excel

> YEARFRAC returns the fraction of a year between two dates, such as 0.5 for six months.

Source: https://spreadsheetpractice.com/functions/yearfrac · Updated October 28, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on October 30, 2026

## Quick answer

- **What it does:** YEARFRAC returns the fraction of a year between two dates, such as 0.5 for six months.
- **Syntax:** `=YEARFRAC(start_date, end_date, [basis])`
- **Most common use:** `=YEARFRAC(B2,$B$5)` returns 7.29 (Ana's years of service, 30/360 basis)
- **Available in:** Every current version
- **Category:** [Date functions](https://spreadsheetpractice.com/functions/category/date)
- **Returns:** A decimal number of years.
- **Google Sheets:** Works the same in Google Sheets.

## What it does

YEARFRAC returns the fraction of a year between two dates, such as 0.5 for six months. Use it for ages and tenure in decimal years, prorated salaries and fees, and accrued interest. The basis argument picks the day-count convention: 0, the default, is the US 30/360 method, and 1 uses actual days.

## Syntax

`=YEARFRAC(start_date, end_date, [basis])`

| Argument | Required? | What it is |
|---|---|---|
| `start_date` | Required | The first date. |
| `end_date` | Required | The second date. The order doesn't matter. |
| `basis` | Optional | Optional: 0 (default) US 30/360, 1 actual/actual, 2 actual/360, 3 actual/365, 4 European 30/360. |

## Examples

Each result was calculated by running the formula on the sample sheet.

| Cell | Formula | Result | What it shows |
|---|---|---|---|
| C2 | `=YEARFRAC(B2,$B$5)` | 7.29 | Ana's years of service, 30/360 basis |
| C3 | `=YEARFRAC(B3,$B$5,1)` | 2.83 | Raj's, using actual days |
| C4 | `=INT(YEARFRAC(B2,$B$5,1))` | 7 | Whole years only: 7 |

### The sample sheet

Every formula above runs on this data:

|  | A | B | C |
|---|---|---|---|
| 1 | Employee | Start date | Years |
| 2 | Ana | 3/15/2019 | 7.29 |
| 3 | Raj | 9/1/2023 | 2.83 |
| 4 |  |  | 7 |
| 5 | As of | 6/30/2026 |  |

## Common mistakes

| What you see | Why, and how to fix it |
|---|---|
| Ages are off by a little | The default basis 0 counts every month as 30 days. Use basis 1 for actual days, or DATEDIF for whole years. |
| #NUM! | basis isn't 0–4. |
| You wanted whole years | Wrap it in INT to drop the fraction: =INT(YEARFRAC(B2,TODAY(),1)). |

## Tips

- For an age exact to the day, =DATEDIF(birthdate,TODAY(),"Y") gives whole years.

## Related functions

- [DATEDIF](https://spreadsheetpractice.com/functions/datedif): DATEDIF counts the complete years, months or days between two dates.
- [DAYS](https://spreadsheetpractice.com/functions/days): DAYS returns the number of days between two dates.
- [EDATE](https://spreadsheetpractice.com/functions/edate): EDATE returns the date a given number of months before or after a start date, keeping the same day of the month.

## Questions

### How do I calculate years between two dates in Excel?

=YEARFRAC(A2,B2,1) gives decimal years using actual days; wrap it in INT for whole years.

### Which basis should I use?

1 (actual/actual) for ages and tenure. Finance agreements often specify 0 (30/360) or 3 (actual/365).

## Practice

A graded YEARFRAC exercise ("Prorated bonus") is on [the YEARFRAC page](https://spreadsheetpractice.com/functions/yearfrac). It is checked instantly, then re-checked on changed data.

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
