Mastering YEARFRAC in Google Sheets: A Practical Guide

Master YEARFRAC in Google Sheets to compute precise year fractions between dates. Learn syntax, basis options, array formulas, and budgeting use cases with clear examples.

How To Sheets
How To Sheets Team
·5 min read
Quick AnswerDefinition

YEARFRAC in Google Sheets returns the fractional part of a year between two dates, based on a chosen day-count basis. It enables precise date math for budgets, project timelines, and attendance calculations. By supplying start date, end date, and a basis (0–4), you get a numeric value representing elapsed years, not just whole years.

YEARFRAC basics in Google Sheets

YEARFRAC returns the fraction of a year between two dates using a day-count basis. The function signature is =YEARFRAC(start_date, end_date, [basis]), where basis can be 0–4 corresponding to different conventions. This makes it ideal for budgeting, project planning, and any analysis requiring precise year-length calculations. When you pass dates as strings, Google Sheets converts them automatically if they are recognizable. The result is a decimal value representing elapsed years, which you can multiply by annual figures or convert to months as needed.

Excel Formula
=YEARFRAC(DATE(2026,1,1), DATE(2026,12,31), 1)

This example uses the Actual/Actual basis (1) and returns approximately 0.997 years. You can also use string dates, but DATEVALUE or DATE is safer for reliability.

Excel Formula
=YEARFRAC("2026-01-01", "2026-12-31", 1)

Calculating fractions between two specific dates

In practice, you often compare two dates in cells, such as A2 and B2. The YEARFRAC formula below computes the fraction of a year between these dates with a consistent basis. The result can be used directly in percentages or multiplied by annual budgets.

Excel Formula
=YEARFRAC(A2, B2, 1)

If A2 and B2 are text dates, wrap them with DATEVALUE to ensure proper conversion:

Excel Formula
=YEARFRAC(DATEVALUE(A2), DATEVALUE(B2), 1)

This approach reduces errors from ambiguous date formats, especially in international datasets.

Choosing the right day-count basis

Google Sheets supports five basis options: 0 through 4. Each basis reflects a different convention for counting days in a year. Basis 1 (Actual/Actual) is common for financial calculations, while Basis 0 (US 30/360) is helpful for simplified calendars. Use the same basis across your dataset to ensure comparability.

Excel Formula
=YEARFRAC(DATE(2026,1,1), DATE(2026,12,31), 0) =YEARFRAC(DATE(2026,1,1), DATE(2026,12,31), 1)

Compare results to understand how basis selection affects the fraction.

Applying YEARFRAC to a column with ARRAYFORMULA

To scale YEARFRAC across many rows, ARRAYFORMULA lets you apply the calculation to an entire column without dragging. Ensure your date pairs are aligned (A2:A with B2:B). The formula below computes the year fraction for each row using the Actual/Actual basis (1).

Excel Formula
=ARRAYFORMULA(IF(LEN(A2:A)=0, , YEARFRAC(A2:A, B2:B, 1)))

This produces a column of results that updates automatically as dates are added.

Handling dates and text input robustly

Dates can arrive as text in real datasets. Convert them with DATEVALUE or DATE to avoid misinterpretation. The following examples demonstrate safe conversion before applying YEARFRAC.

Excel Formula
=YEARFRAC(DATEVALUE(A2), DATEVALUE(B2), 1)

If either date is missing, you can guard with IFERROR to return a friendly message:

Excel Formula
=IFERROR(YEARFRAC(DATEVALUE(A2), DATEVALUE(B2), 1), "Invalid date")

Practical budgeting and forecasting use cases

YEARFRAC supports budgeting by converting date spans into year-based factors. For example, you can compute the fraction of a year between project start and end dates and multiply by annual costs to estimate mid-year burn. Here’s a compact example using explicit dates:

Excel Formula
=YEARFRAC(DATE(2024,1,15), DATE(2026,6,15), 1) * 120000

This yields an estimated pro-rated cost for the defined period. You can expand this with ARRAYFORMULA for multiple projects:

Excel Formula
=ARRAYFORMULA(IF(LEN(A2:A)=0, , YEARFRAC(A2:A, B2:B, 1) * C2:C))

Comparing bases and validating results

If you’re unsure which basis to apply, compute the same span with multiple bases and compare. This helps in audit trails and documentation. Example:

Excel Formula
=YEARFRAC(A2, B2, 0) =YEARFRAC(A2, B2, 1) =YEARFRAC(A2, B2, 2)

Note that 0 and 4 often yield different fractions due to day-count conventions. Validate against your domain standard before finalizing.

Troubleshooting common issues

Date parsing failures are the most common source of errors. Always normalize inputs with DATE, DATEVALUE, or DATEVALUE(DATE()) before YEARFRAC. If dates are reversed (start after end), YEARFRAC still returns a value, but sometimes it’s negative depending on basis. Guard with an absolute check:

Excel Formula
=IF(A2<=B2, YEARFRAC(A2,B2,1), -YEARFRAC(B2,A2,1))

This clarifies interpretation and prevents silent logic errors.

Combine YEARFRAC with other date functions for richer analytics. For example, compare two spans or convert the result to months or days:

Excel Formula
=YEARFRAC(DATE(2026,1,1), DATE(2026,12,31), 1)

To convert the year fraction to days approximately, multiply by 365:

Excel Formula
=YEARFRAC(DATE(2026,1,1), DATE(2026,12,31), 1) * 365

You can also subtract fractions to measure duration differences:

Excel Formula
=YEARFRAC(A2, B2, 1) - YEARFRAC(A3, B3, 1)

Steps

Estimated time: 15-25 minutes

  1. 1

    Open your sheet and identify date columns

    Start by locating the two columns containing start and end dates. Ensure they are consistently formatted as dates, not text. This reduces data-cleaning work later.

    Tip: Use named ranges for repeatable references.
  2. 2

    Choose a basis and write the initial YEARFRAC

    Decide the day-count basis (0-4) based on your domain standard. Write a basic YEARFRAC formula to verify correct parsing of dates and the chosen basis.

    Tip: Document which basis you select for future audits.
  3. 3

    Apply YEARFRAC to a single row for testing

    Test with a known date pair to confirm results. Compare with a manual year-difference to sanity-check decimals.

    Tip: Use DATEVALUE to ensure text dates are parsed.
  4. 4

    Scale to a range with ARRAYFORMULA

    Replace per-row formulas with an ARRAYFORMULA to handle entire columns. This saves manual edits as data grows.

    Tip: Validate the resulting array length matches input rows.
  5. 5

    Guard against invalid dates with IFERROR

    Wrap YEARFRAC with IFERROR to handle missing or malformed data gracefully.

    Tip: Return a friendly message instead of an error.
  6. 6

    Incorporate into budgeting forecasts

    Multiply the year-fraction by annual costs to estimate pro-rated expenses over time.

    Tip: Keep a separate worksheet for assumptions.
Pro Tip: Prefer date-based basis 1 (Actual/Actual) for financial calculations.
Warning: Be consistent with basis across the dataset to avoid misleading results.
Note: DATEVALUE converts text dates to proper date values when needed.

Prerequisites

Required

Optional

  • Basic knowledge of ARRAYFORMULA for ranges
    Optional

Keyboard Shortcuts

ActionShortcut
CopyCopy formula or dataCtrl+C
PasteInsert copied contentCtrl+V
Format cellsOpen number/date formattingCtrl+1
Fill down / Auto-fillExtend formulas down a columnCtrl+D

FAQ

What does YEARFRAC return in Google Sheets?

YEARFRAC returns the fractional part of a year between two dates based on a specified day-count basis. The result is a decimal representing elapsed years, not just whole years.

YEARFRAC gives you a decimal year between two dates, using a chosen basis for day counting.

Which basis should I use for typical budgets?

For budgets and schedules, basis 1 (Actual/Actual) is commonly used, but ensure you apply the same basis across all calculations for consistency.

Actual/Actual is a common choice, but stay consistent across your sheet.

Can YEARFRAC handle text dates?

Yes, convert text dates with DATEVALUE or DATE to ensure correct parsing before applying YEARFRAC.

Text dates can work if you convert them to real dates first.

How do I apply YEARFRAC to an entire column?

Use ARRAYFORMULA to apply YEARFRAC to a pair of date columns, returning results for every row without manual dragging.

Use ARRAYFORMULA to apply to whole columns.

What are common errors with YEARFRAC?

Common issues include misformatted dates and inconsistent basises. Validate input types and keep a single basis.

Check date formats and stay consistent with the basis.

The Essentials

  • Use YEARFRAC for precise year fractions
  • Choose an appropriate basis and stay consistent
  • Scale with ARRAYFORMULA for large datasets
  • Guard with IFERROR to handle bad input

Related Articles