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
Arguments
| Argument | required / optional | Description |
|---|---|---|
start_date | required | The earlier date. |
end_date | required | The later date. |
basis | optional | Day-count convention: 0 US 30/360 (default), 1 actual/actual, 2 actual/360, 3 actual/365, 4 European 30/360. |
Related functions
Select the result cell and type =YEARFRAC(.
Select the earlier date, a comma, then the later date.
Add a comma and 1 for actual/actual unless you specifically need a 30/360 bond convention.
Format the result as a number with two or more decimals.
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
YEARFRACwhere whole completed years are wanted;DATEDIFwith "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.