YEARFRAC Function in Excel

“yearfrac function in excel” comes up constantly, so this page leads with the exact answer, gives you a tool to try it on your own numbers, and only then explains the detail. Everything works in Excel on Windows and Mac and maps almost one-to-one to Google Sheets. Copy the answer above and get back to work, or read on to turn a one-off fix into something you never have to look up again.

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.

Syntax

=YEARFRAC(start_date, end_date, [basis])

Arguments

ArgumentDescription
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
ƒxDate Difference CalculatorLive
Days between
364

Breakdown: 0 years · 11 months · 30 days

Workdays (Mon–Fri, NETWORKDAYS)
261
=B2A2 · =NETWORKDAYS(A2,B2)
Ctrl+CthenCtrl+Shift+V+Cthen+Ctrl+VPaste values · WindowsMac

Need it as an auditable file?

Ships inside the linked template — formula-driven, unlocked, audit-ready.

View template

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. One habit worth forming early: name the cells that hold your inputs, so the formula reads in plain language instead of a string of cell addresses. A reviewer — or you in three months — can then follow the logic without decoding what B7 and D2 were supposed to mean, which is most of what makes a sheet maintainable.

In Google Sheets

Google Sheets handles this almost identically to Excel. The formula syntax above is the same, and the menu lives under a slightly different label rather than a ribbon tab. Use the platform toggle at the top of the page to switch every keyboard shortcut between Windows and Mac, and expect at most cosmetic differences in naming. 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, the tool proves it, and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. If you take one thing from this page on “yearfrac function in excel”, make it the habit rather than the keystrokes: set the problem up with labelled inputs, reference those cells, and let Excel do the recomputing. Bookmark the page for the syntax, but do the example once in a blank sheet and check it against the tool above — five minutes of hands-on practice fixes the method in memory far better than re-reading, and it surfaces the small snags while they are still harmless. After that the technique is genuinely yours: faster than searching for it again, and reliable enough to drop into work that other people depend on.

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.