ExcelReady
CourseFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before the interview. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Function guides
  • Blog

Product

  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Dates
  3. YEARFRAC in Excel: Part of a Year Between Two Dates

YEARFRAC in Excel: Part of a Year Between Two Dates

By ExcelReady Team·Updated October 30, 2026·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+
  1. What does YEARFRAC do?
  2. How to use YEARFRAC step by step
  3. Which basis should you use?
  4. How to prorate a salary or bonus
  5. How to get whole years or round the result
  6. YEARFRAC vs DATEDIF
  7. Common YEARFRAC mistakes
  8. Practise it

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.

Excel formula
=YEARFRAC(start_date, end_date, [basis])
ArgumentWhat it means
start_dateThe first date
end_dateThe second date
basisOptional. 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:

ABCD
1EmployeeStart dateReview dateTenure (years)
2Jordan Price6/1/20219/30/20254.33
3Mei Chen1/9/20239/30/20252.72
4Carlos Diaz11/18/20199/30/20255.87
5Samir Patel4/1/20249/30/20251.50
  1. Click D2 and type =YEARFRAC(.
  2. Click B2 for the start date and type a comma.
  3. Click C2 for the end date and type a comma.
  4. Type 1 for actual days, close the bracket and press Enter.
Excel formula
=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:

BasisNameHow it counts
0 or omittedUS (NASD) 30/360Every month is 30 days, every year 360
1Actual/actualReal days ÷ real year length
2Actual/360Real days ÷ 360
3Actual/365Real days ÷ 365
4European 30/360Like 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:

FormulaResult
=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:

Excel formula
=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:

Excel formula
=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():

Excel formula
=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.

DATEDIFYEARFRAC
ReturnsWhole years, months or daysDecimal years
Jordan's tenure4 (with "Y")4.33
Date orderStart must be first, or #NUM!Either order
Shows in function listNo (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.

fx
ABCDE
1
Employee
Start date
Review date
Tenure (years)
2
Jordan Price
44348
45930
3
Mei Chen
44935
45930
4
Carlos Diaz
43787
45930
5
Samir Patel
45383
45930
6
7
8

Tip: Start date first, then end date, then 1 for actual days.

Practise this in a lesson

LessonDays between dates: DAYS, DATEDIF and TODAYMeasure the gap between two dates in days, months and years, and calculate tenure as of today.Function guideDATEDIFCalculate tenure, age and contract length with DATEDIF. Learn every unit (Y, M, D, YM), the hidden-function quirks, and practice live.

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.

Sources

  • YEARFRAC function - Microsoft Support
  • DATEDIF function - Microsoft Support

Written and checked by the ExcelReady Team. First published October 30, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What does YEARFRAC do?
  2. How to use YEARFRAC step by step
  3. Which basis should you use?
  4. How to prorate a salary or bonus
  5. How to get whole years or round the result
  6. YEARFRAC vs DATEDIF
  7. Common YEARFRAC mistakes
  8. Practise it

Keep reading

Dates· 6 min read

Days Until a Deadline in Excel (Countdowns)

To count the days until a date in Excel, subtract today from it: =A2-TODAY(). The result updates every day and turns negative once the date has passed. Wrap it in IF to show "Overdue" or "Due today", and use =NETWORKDAYS(TODAY(),A2) to count only the working days left.

Dates· 7 min read

First and Last Day of the Month in Excel

For the first day of the month in Excel, use =EOMONTH(A2,-1)+1: the last day of the previous month plus one day. You can also write =DATE(YEAR(A2),MONTH(A2),1). For the last day of the month, use =EOMONTH(A2,0). Change the month number in EOMONTH to move to next month (1) or last month (-1).

Tests & careers· 5 min read

Excel Skills for HR and Recruiting Jobs

The most useful Excel skills for HR and recruiting are counting headcount with COUNTIFS, totalling payroll with SUMIFS, calculating tenure and time to hire with DATEDIF, TODAY and date subtraction, looking up employee records with XLOOKUP or VLOOKUP, flagging eligibility with IF and AND, and cleaning names and dates so reports stay accurate.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback. The first lessons are free, with no download.

Start learning for free