YEARFRAC
Returns the fraction of a year between two dates for a selected day-count basis.
The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.
Syntax
=YEARFRAC(start_date, end_date, [basis])
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
start_date | number | Required | — |
end_date | number | Required | — |
basis | number | Optional | — |
Remarks
- A date argument may be text holding a date or time (
"10/26/1999","1999-10-26 14:05"), read as its serial; text that is neither a number nor a date returns#VALUE!. - Supported
basisvalues:0(US 30/360),1(actual/actual),2(actual/360),3(actual/365),4(European 30/360). - The dates are ordered first, so swapping them gives the same positive result.
- Basis
0follows Excel's US 30/360 month-end rules, which differ fromDAYS360's: an end day of 31 becomes 30 only when the start day is 30 or 31, and February month-ends are adjusted on the start date (on both dates when both are the last day of February). - Basis
1divides by 366 or 365 for periods up to a year (366 when the period is in a leap year or covers February 29) and by the average year length otherwise. - Serial dates are interpreted with the workbook's date system (Excel 1900 or Excel 1904).
Error cases
- Invalid
basisvalues return#NUM!.
Examples
Measure half a calendar year using the default financial convention.
Formula =YEARFRAC(DATE(2024,1,1),DATE(2024,7,1))
Expected result 0.5
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Use actual elapsed days and a 365-day denominator.
Formula =YEARFRAC(DATE(2024,1,1),DATE(2024,7,1),3)
Expected result 0.498630136986301
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Identical dates have a year fraction of zero.
Formula =YEARFRAC(45000,45000)
Expected result 0
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Basis 99 is outside the supported day-count conventions.
Formula =YEARFRAC(45000,45100,99)
Expected result #NUM!
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Actual/360 convention
Formula =YEARFRAC(44197, 44378, 2)
Expected result 0.502777777777778
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Actual/365 convention
Formula =YEARFRAC(44197, 44378, 3)
Expected result 0.495890410958904
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Related functions
FAQ
How does the basis argument change YEARFRAC?
Basis selects the day-count convention (actual or 30/360 variants), so the same dates can yield different fractions.