YEARFRAC Function in Excel

If you just need to yearfrac function in excel and move on, the boxed answer at the top is all you need. The rest of this page is for when you want to understand why it works in Excel, adapt it to a trickier version, or make it robust enough to hand to a colleague. We keep the opening short on purpose — the depth is here when you want it, not in your way when you don’t.

Exact answer

In Excel: use =YEARFRAC(start_date, end_date, 1) — it returns the fraction of a year between two dates, and the basis argument matters more than it looks.

On this page8

Syntax

=YEARFRAC(start_date, end_date, [basis])

Arguments

Argumentrequired / optionalDescription
start_daterequiredThe earlier date.
end_daterequiredThe later date.
basisoptionalDay-count convention: 0 US 30/360 (default), 1 actual/actual, 2 actual/360, 3 actual/365, 4 European 30/360.

Related functions

DATEDIFEDATERRI
▤Annotated stepsExcel
1

Select the result cell and type =YEARFRAC(.

2

Select the earlier date, a comma, then the later date.

3

Add a comma and 1 for actual/actual unless you specifically need a 30/360 bond convention.

4

Format the result as a number with two or more decimals.

Ctrl+CthenCtrl+Shift+V⌘+Cthen⌘+Ctrl+VPaste values · WindowsMac

What this does

YEARFRAC returns how much of a year lies between two dates, as a decimal. Its use is anywhere a partial period must be priced or apportioned: accrued interest, pro-rata subscriptions, tenure in years. The basis argument selects the day-count convention, and the default of 0 is the US 30/360 rule which assumes every month has 30 days — fine for bond maths, wrong for anything measuring actual elapsed time. Passing 1 uses actual days over the actual year length and is what most non-bond calculations want. Getting this argument wrong produces answers that are subtly, plausibly incorrect. Most people learn this as a sequence of clicks and forget it by next week; learning it as a pattern instead is what lets you apply it to the next, slightly different version of the problem without starting from scratch. That is the difference this page is trying to make. For “yearfrac function in excel”, the reliable version is a short checking loop, not just the first command that appears to work. Run it on a deliberately small range first, watch how the affected formula change, and only then apply the same setup to the full sheet. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. That is what makes a calculation you can defend to a CFO or an auditor useful in real work: repeatable, auditable, and not dependent on memory or luck.

A worked example

Tenure in years including the part-year: =YEARFRAC(hire_date, TODAY(), 1) returns 7.42. Pro-rata annual fee for a mid-year start: =YEARFRAC(A2, "2026-12-31", 1) * 1200. The basis difference in action: between 31 January and 28 February, basis 0 returns 0.0778 and basis 1 returns 0.0767 — small, but wrong money is wrong money. YEARFRAC prices the partial period, and its basis argument is the difference between an accrual that reconciles and one that is quietly off. Check the referenced cells, argument order and result type in your workbook. Start with the worked example before changing an input, then compare the changed result with the calculation you expected. An error value or a result of a different type is a reason to inspect the inputs and arguments.

In Google Sheets

Google Sheets support for this task has not been verified. Check the function, arguments and workflow in the target product before transferring the example. Matching formula notation does not establish identical behaviour. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. For “yearfrac function in excel”, keep the input cells and the result visible while you check the formula in Excel. Follow the worked example and change one input at a time. The steps explain the workbook calculation; this page does not run a live calculator for that task.

Common mistakes

  • Leaving the basis at the default 0, which assumes 30-day months and misstates elapsed time.
  • Passing the dates in the wrong order, which returns a negative fraction.
  • Using YEARFRAC where whole completed years are wanted; DATEDIF with "Y" is the one for that.

Frequently asked questions

Which basis should I use?

Basis 1 (actual/actual) for anything measuring real elapsed time. The 30/360 conventions exist for bond maths.

What is the difference from DATEDIF?

DATEDIF returns whole completed units; YEARFRAC returns a decimal including the partial period.

How do I calculate tenure in years?

=YEARFRAC(hire_date, TODAY(), 1) for the decimal, or =DATEDIF(hire_date, TODAY(), "Y") for completed years only.