YEARFRAC in Excel: Part of a Year Between Two Dates
By ExcelReady TeamUpdated 7 min read
The short answer
YEARFRAC returns the time between two dates as a fraction of a year, such as 0.5 for six months. Write =YEARFRAC(start_date, end_date, [basis]). Use basis 1 (actual days) for tenure, age and prorating; the default, basis 0, treats every month as 30 days, as many US finance calculations do. Wrap it in INT for whole years.
Key takeaways
- =YEARFRAC(start, end, 1) gives decimal years using actual calendar days.
- Leaving basis out uses 0 (US 30/360), which can differ slightly from actual days.
- INT(YEARFRAC(...)) gives whole years; ROUND(..., 1) gives one decimal place.
- Multiply by an annual amount to prorate salary, bonus or budget for part of a year.
- DATEDIF counts complete units; YEARFRAC gives the fraction in between.
On this page+
YEARFRAC in Excel returns the time between two dates as a fraction of a year, so six months comes back as 0.5 and four years and four months as about 4.33. Use it for tenure in decimal years, age with decimals, and prorating an annual salary, bonus or budget. This guide explains the syntax, which basis to pick, and how YEARFRAC differs from DATEDIF.
What does YEARFRAC do?#
YEARFRAC counts the days between two dates and divides by the length of a year. The result is a decimal number of years.
=YEARFRAC(start_date, end_date, [basis])| Argument | What it means |
|---|---|
start_date | The first date |
end_date | The second date |
basis | Optional. How to count days and years (see the table below). Default is 0 |
From January 1 to July 1, 2024, =YEARFRAC(A2,B2) returns 0.5. The order of the dates doesn't matter: YEARFRAC always returns a positive number. It works in every version of Excel.
How to use YEARFRAC step by step#
Here are four employees and the date of their last review:
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Employee | Start date | Review date | Tenure (years) |
| 2 | Jordan Price | 6/1/2021 | 9/30/2025 | 4.33 |
| 3 | Mei Chen | 1/9/2023 | 9/30/2025 | 2.72 |
| 4 | Carlos Diaz | 11/18/2019 | 9/30/2025 | 5.87 |
| 5 | Samir Patel | 4/1/2024 | 9/30/2025 | 1.50 |
- Click D2 and type
=YEARFRAC(. - Click B2 for the start date and type a comma.
- Click C2 for the end date and type a comma.
- Type
1for actual days, close the bracket and press Enter.
=YEARFRAC(B2,C2,1)Jordan's tenure is 4.33 years (shown to two decimals). Fill down with Ctrl+D on Windows or ⌘D on a Mac. If you see a long decimal, set the number of decimal places with Home > Decrease Decimal, or wrap the formula in ROUND.
Which basis should you use?#
The basis tells YEARFRAC how to count. There are five options:
| Basis | Name | How it counts |
|---|---|---|
| 0 or omitted | US (NASD) 30/360 | Every month is 30 days, every year 360 |
| 1 | Actual/actual | Real days ÷ real year length |
| 2 | Actual/360 | Real days ÷ 360 |
| 3 | Actual/365 | Real days ÷ 365 |
| 4 | European 30/360 | Like 0, with a slightly different month-end rule |
For HR, age, tenure and most business work, use basis 1. It counts real calendar days and real year lengths, including leap years. When the dates span several years, it divides by the average year length over those years.
Bases 0 and 4 come from finance, where interest is often calculated on a 30/360 day count. They can give slightly different results from real days. From March 31 to June 30, 2025:
| Formula | Result |
|---|---|
=YEARFRAC(A2,B2,0) | 0.2500 |
=YEARFRAC(A2,B2,1) | 0.2493 |
=YEARFRAC(A2,B2,2) | 0.2528 |
=YEARFRAC(A2,B2,3) | 0.2493 |
The differences are small, but they matter in payroll and contracts. If a policy names a day-count rule, match it. Otherwise, choose 1 and use it everywhere.
How to prorate a salary or bonus#
Multiply YEARFRAC by the annual amount to get the share for part of a year. A new hire starts on April 1, 2025 with an annual bonus target of 48,000, paid for the time worked up to December 31:
=ROUND(YEARFRAC(B2,C2,1)*D2,2)April 1 to December 31 is 274 days, and 274 ÷ 365 = 0.7507, so the prorated bonus is 36,032.88. ROUND keeps it to cents. Check your own policy on whether the end date counts as a full day: if it should, add 1 to the end date, YEARFRAC(B2,C2+1,1).
Prorating comes up often in HR and payroll tasks. Our guide to Excel skills for HR jobs lists the other formulas those tests expect.
How to get whole years or round the result#
Wrap YEARFRAC in INT to drop the decimals and get completed years:
=INT(YEARFRAC(B2,C2,1))For Jordan this returns 4. Use =ROUND(YEARFRAC(B2,C2,1),1) for one decimal place (4.3).
For age, the same pattern works with a birth date and TODAY():
=INT(YEARFRAC(B2,TODAY(),1))TODAY() updates every day, so the age stays current. Our guide on calculating age or years of service compares this with DATEDIF and covers leap-day birthdays.
YEARFRAC vs DATEDIF#
Use DATEDIF for complete units and YEARFRAC for the fraction in between.
| DATEDIF | YEARFRAC | |
|---|---|---|
| Returns | Whole years, months or days | Decimal years |
| Jordan's tenure | 4 (with "Y") | 4.33 |
| Date order | Start must be first, or #NUM! | Either order |
| Shows in function list | No (hidden function) | Yes |
| Typical use | "4 years, 3 months" | Prorating, averages, charts |
The DATEDIF function guide explains its units, such as "Y", "M" and "YM". If you just need the number of days between two dates, subtraction or DAYS is simpler; see how to count days between dates.
Common YEARFRAC mistakes#
These are the issues that cause wrong or surprising answers:
- Leaving out the basis. The default 30/360 count is fine for finance but can be off by a day or two of real time. Type 1 unless you need 30/360.
- Expecting whole years. YEARFRAC returns decimals. Use INT for completed years.
- Rounding up tenure. ROUND(4.6,0) gives 5, though the person has only 4 full years. Use INT for service-based rules.
- Text dates. YEARFRAC returns #VALUE! if a date is text that Excel can't read.
- Month-end edge cases with basis 0. 30/360 treats every month as 30 days, so spans that include the 31st or the end of February can differ from the real day count by a day or two.
YEARFRAC also pairs well with month boundaries. To prorate from the first of the month, use the first or last day of the month as your start or end date; to count down instead of measuring, see days until a deadline.
Practise it#
Try the tenure exercise on this page. Then open the days between dates lesson, where you measure tenure with subtraction, DAYS and DATEDIF in a live spreadsheet and see how each one counts.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
HR wants each employee's tenure at the last review in decimal years. In D2, use YEARFRAC with the start date in B2, the review date in C2 and basis 1.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Tenure (years) | ||||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 | |||||
| 6 | |||||
| 7 | |||||
| 8 |
Tip: Start date first, then end date, then 1 for actual days.
Practise this in a lesson
Frequently asked questions
What does YEARFRAC do in Excel?
YEARFRAC returns the number of years between two dates as a decimal. From January 1 to July 1, 2024 it returns 0.5 with the default basis.
Which basis should I use in YEARFRAC?
Use 1 (actual/actual) for HR, age and general calculations, because it counts real calendar days. Use 0 or 4 only when a finance rule asks for a 30/360 day count.
What is the difference between YEARFRAC and DATEDIF?
DATEDIF counts complete years, months or days, so a gap of 4 years and almost 4 months returns 4 with the "Y" unit. YEARFRAC returns the fraction, about 4.33.
Does the order of the dates matter in YEARFRAC?
No. YEARFRAC returns a positive result whichever date comes first. DATEDIF, by contrast, returns #NUM! if the start date is after the end date.
How do I calculate age with decimals in Excel?
Use =YEARFRAC(birth_date, TODAY(), 1). Wrap it in ROUND(…,1) for one decimal place, or INT for whole years.