How to calculate elapsed years as a decimal (YEARFRAC)
✓ Verified in LibreOffice 25.8.7.3Get the fraction of a year between two dates — accruals, prorating, service length.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel | =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. Every formula here is confirmed by actually executing it.