YEARFRAC

Short answer

Accrue interest on the day count the agreement specifies

YEARFRAC(start_date, end_date, [basis])
Excel version
All versions
Also searched as
day count convention, fraction of a year, 30/360, actual/360, actual/365, accrued interest, prorate by year

What it returns

YEARFRAC returns the fraction of a year between two dates, measured by a day count convention. Half a year comes back as about 0.5. Multiply it by an annual rate and a principal and you have the interest for the period.

The convention is what makes it more than date subtraction. “Half a year” is 180 days out of 360 under 30/360, the actual days out of 360 under actual/360, and the actual days out of 365 under actual/365. On the same two dates those give different answers, and loan agreements, bonds and leases each specify which one applies.

The default, when basis is omitted, is US (NASD) 30/360. Many models omit it and silently accrue on a convention the underlying agreement does not use.

Arguments that matter

ArgumentRequiredWhat it does
start_dateYesStart of the period. Real date. Truncated to a whole day.
end_dateYesEnd of the period. Order does not change the sign: YEARFRAC always returns a positive fraction.
basisNoThe day count convention, 0 to 4. Omitted means 0.
basisConventionTypical use
0 or omittedUS (NASD) 30/360US corporate bonds, fixed-rate notes, US mortgages
1Actual/actualExcel’s own actual/actual rule; see the caveat below
2Actual/360Floating-rate loans and money markets in USD and EUR
3Actual/365GBP lending, many leases, simple internal accruals
4European 30/360Eurobonds and some European loan documents

A basis below 0 or above 4 returns #NUM!. A date Excel cannot read returns #VALUE!.

Treat the basis as an input with a source. It belongs on the assumptions tab next to the rate it applies to, stamped with the clause it came from, per source-stamp every assumption.

In a financial model

YEARFRAC turns dates into the time factor for anything that accrues:

  • Interest on debt. Opening balance × rate × YEARFRAC(period start, period end, basis). This handles irregular first periods and drawdowns mid-month, which a flat rate/12 cannot.
  • Accruals and prepaids. The share of an annual contract or insurance premium that falls in a period.
  • Discount factors. 1/(1+r)^YEARFRAC(valuation date, cash flow date, 3) gives a dated discount factor that matches XNPV’s actual/365 convention.

When a rate is quoted, its convention travels with it. A SOFR loan at actual/360 and a fixed-rate note at 30/360 can sit in the same debt schedule with different bases, and date every rate applies to the convention as much as to the number.

Worked example

A $10,000,000 loan at 6.00%, interest period from 15 January 2026 to 15 July 2026. That is 181 actual days.

=Principal * Rate * YEARFRAC(Start, End, Basis)
BasisConventionYEARFRACInterest
0US 30/3600.500000$300,000.00
1Actual/actual0.495890$297,534.25
2Actual/3600.502778$301,666.67
3Actual/3650.495890$297,534.25
4European 30/3600.500000$300,000.00

The gap between actual/360 and actual/365 on one six-month period is $4,132.42. Actual/360 always produces more interest than actual/365 on the same rate, because a year of 360 days makes each day a larger share of it. Over a five-year, $10 million facility that is real money, and it is the first thing a lender’s agent will reconcile against your model.

In a monthly debt schedule, with period-start dates in row 8 and period-end dates in row 9:

=D$20 * Inputs!$C$12 * YEARFRAC(D$8, D$9, Inputs!$C$13)

D20 is the opening balance, C12 the annual rate and C13 the basis, both on the inputs tab with their source.

Old way vs new way

The common shortcut is a flat monthly rate:

=D$20 * Inputs!$C$12 / 12

That is exactly right only under 30/360 for full calendar months. Under actual/360, January interest is 31/360 of a year and February is 28/360, so the flat version overstates February and understates January. The YEARFRAC version follows the agreement:

=D$20 * Inputs!$C$12 * YEARFRAC(D$8, D$9, Inputs!$C$13)

Where it breaks

A full year accrues 364 days. Prorating a calendar year from 1 January to 31 December under basis 1 or 3 returns 0.997260, because YEARFRAC counts the days between the two dates, not the days inclusive of both. Under basis 0 the same dates return 1.000000. Fix: make the end date the start of the next period, 1 January to 1 January. That returns exactly 1 under bases 0, 1 and 4. Under basis 2 it returns 1.013889, because 365 days over 360 is more than a year, and under basis 3 a leap year returns 1.002740. Both are correct for those conventions. Period start dates and next-period start dates are the cleanest pair to feed it.

The model omits basis and the lender uses actual/360. Interest is understated every period. Fix: never omit the argument. Write the basis explicitly even when it is 0, so a reviewer sees that someone chose it.

February accruals look wrong under 30/360. Microsoft documents that basis 0 can return an incorrect result when the start date is the last day of February. Fix: test any schedule that starts on 28 or 29 February against the agreement’s own worked example, and override the edge period if they differ.

Actual/actual does not match the bond documents. Basis 1 is Excel’s own actual/actual rule. It is not the ISDA actual/actual method, which splits a period at each year-end and divides each piece by the length of its own year. Across a year-end that includes a leap year, the two can differ. Fix: for ISDA terms, split the period at 31 December and divide each piece’s actual days by 365 or 366, whichever its own year has.

Times disappear. Both dates are truncated to whole days. An intraday drawdown accrues from the start of that day. Fix: none needed for loans, which accrue in whole days. Note it if a model claims hourly precision.

Related functions

  • EDATE. Produces the payment and maturity dates YEARFRAC measures between.
  • EOMONTH. Produces month-end period boundaries for a monthly accrual schedule.
  • DAYS. The raw day count, for when the agreement states a formula in days rather than a convention name.
  • XNPV and XIRR. Both fix their time factor at actual/365. YEARFRAC with basis 3 reproduces it outside those functions.
  • The play date every rate covers the as-of date; the basis is the other half of the rate’s definition.

All functions