Skip to content

yearfrac

Fraction of a year between two dates.

v = yearfrac(start_date, end_date, basis)

Returns the years (with fractional part) between the dates. basis selects the day-count convention: 0 (US 30/360, default), 1 (actual/actual), 2 (actual/360), 3 (actual/365), 4 (European 30/360).

yearfrac(date(2026,1,1), date(2026,7,1)) % 0.5
  • days — Number of days between two dates.
  • days360 — Number of days between two dates using a 360-day year (30-day months).
  • datedif — Difference between two dates in a chosen unit.