← All how-to recipes

How to calculate elapsed years as a decimal (YEARFRAC)

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Get the fraction of a year between two dates — accruals, prorating, service length.

The formula

AppFormulaNotes
Excel (desktop)=YEARFRAC(A2,B2,1)Basis 1 = actual/actual (real calendar). Basis 0 (default) is the 30/360 bond convention.
Google Sheets=YEARFRAC(A2,B2,1)Identical.
LibreOffice Calc=YEARFRAC(A2,B2,1)Identical.

How it works

YEARFRAC turns two dates into decimal years. The basis argument picks the day-count convention: 0 (default) is 30/360 — every month counts as 30 days, so Jan 1 to Jul 1 is exactly 0.5 — while basis 1 uses the actual calendar (181/365 ≈ 0.4959 for the same dates). Use 30/360 for bond-style finance, actual/actual for real elapsed time like tenure or prorated fees. A simpler approximation, (B2-A2)/365.25, is fine when the convention doesn't matter.

Verified, not just documented

We ran =ROUND(YEARFRAC(DATE(2026,1,1),DATE(2026,7,1),0),4) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 0.5 — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 0.5 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.

Functions used

YEARFRAC — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related comparisons