YEARFRAC Function (Gnumeric)
Learn the YEARFRAC function in Gnumeric: Returns the number of years (including fractional part) between two dates.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Gnumeric. How formula examples are checked
YEARFRAC estimates the time between two dates as a fraction of a year according to a selected day-count basis. It is useful for pro-rated fees, financial year fractions, eligibility periods and time-based comparisons. The result is not necessarily calendar months divided by 12: it depends on how the basis counts days and defines a year.
Gnumeric syntax and arguments
=YEARFRAC(start_date, end_date, [basis])
start_date — Required. Beginning date serial or date-cell reference.
end_date — Required. Ending date serial or date-cell reference.
basis — Optional. Day-count convention, default 0 (US 30/360). Gnumeric 1.12.62 accepts 0 through 4; unsupported values and invalid dates give #NUM!.
The official Gnumeric date header and gnumeric_yearfrac code define the basis table:
On a narrow screen, scroll this table sideways to see every column.
| Basis | Day-count convention | Practical meaning |
|---|---|---|
0 (default) |
US 30/360 | Each month is treated using the US 30/360 convention. |
1 |
Actual/actual | Actual calendar-day differences and actual year length(s). |
2 |
Actual/360 | Actual days divided by 360. |
3 |
Actual/365 | Actual days divided by 365. |
4 |
European 30/360 | European 30/360 convention. |
Gnumeric formulas here use commas and DATE(year,month,day) to avoid regionally ambiguous date strings. The output is numeric, and changing the cell’s date format does not change the underlying fractional value. A 0.00 format can hide meaningful precision, so add more decimal places when comparing bases.
Worked examples with fixed dates
The interval January 1 through July 1, 2024 contains 182 elapsed days (2024 is a leap year). Try these formulas:
On a narrow screen, scroll this table sideways to see every column.
| Formula | Expected numeric result | Calculation |
|---|---|---|
=YEARFRAC(DATE(2024,1,1),DATE(2024,7,1)) |
0.5 |
Default US 30/360: 180/360. |
=YEARFRAC(DATE(2024,1,1),DATE(2024,7,1),2) |
0.505555556 |
182 actual days / 360. |
=YEARFRAC(DATE(2024,1,1),DATE(2024,7,1),3) |
0.498630137 |
182 / 365. |
=YEARFRAC(DATE(2024,1,1),DATE(2024,7,1),4) |
0.5 |
European 30/360: 180/360. |
Results are rounded here for display; sheet cells can show additional digits. These are independently calculated expectations, not results obtained by executing Gnumeric 1.12.62. For basis 1 the actual/actual method may depend on whether the interval spans years; test the precise required convention in your installed version before using it for financial reporting.
Reproducible input table
| Cell | Enter |
|---|---|
A2 |
=DATE(2024,1,1) |
B2 |
=DATE(2024,7,1) |
C2 |
3 |
D2 |
=YEARFRAC(A2,B2,C2) |
Expected D2: approximately 0.498630137. Formatting A2 and B2 as dates and D2 as a number with nine decimals makes the comparison easier.
Advanced use: pro-rating and reporting
If E2 contains an annual fee (for example 1200), a simple Actual/365 prorated fee for the A2–B2 interval is:
=E2*YEARFRAC(A2,B2,3)
With the example dates and E2=1200, the independently calculated expected result is approximately 598.3561644 before currency rounding. Apply your organization’s contractual day-count convention instead of assuming Actual/365 is universally correct.
Check the order of user-entered dates before calculating:
=IF(B2<A2,"Check date order",YEARFRAC(A2,B2,3))
This guard is useful for preventing an unexpected negative or reversed-duration report; it is a validation policy, not an assertion that Gnumeric necessarily rejects reversed dates.
Errors, pitfalls and cross-software cautions
#NUM!: the tagged source rejects an invalid date or a basis outside its accepted range of0–4. Check input cells and selected basis.- Unexpected fraction: the default is US 30/360, not actual-day / 365. Specify basis explicitly in financial models.
- End-of-month differences: US and European 30/360 can disagree at month ends. Test the convention required by your contract and audit a known example.
- Leap days: 2024 has 366 days, but basis
3still divides actual elapsed days by 365. That is an intentional definition, not a leap-year adjustment. - Locale and dates: enter dates with
DATE()or references to validated date cells; CSV strings like03/04/2024may parse differently. - Excel/LibreOffice compatibility: day-count basis codes
0–4are common, but exact edge cases (1900 date system, month ends, actual/actual intervals) and imported date-system settings require target-application testing. No cross-application native equivalence was established in this review.
Related functions
Official references and testing disclosure
- Gnumeric public function catalogue — checked October 11, 2026; the public project lists YEARFRAC as Complete / No Testsuite.
- Gnumeric 1.12.62 Date/Time implementation —
help_yearfrac,gnumeric_yearfrac, and the function descriptor, inspected October 11, 2026. - Gnumeric 1.12.62 day-count basis definitions —
GNM_DATE_BASIS_HELP, inspected October 11, 2026.
How this guide was checked
The syntax and behaviour are based on the Gnumeric references cited above. The sample calculations were independently checked; they are expected results, not outputs observed in Gnumeric. Test locale-sensitive text conversion and imported files in your own installation. View the example-check record.