YEARFRAC in Google Sheets: How to Use It

How-to basics · Updated November 23, 2026

The Google Sheets YEARFRAC function returns the number of years (including fractional years) between two dates, using a specified day-count convention. For example, =YEARFRAC("2024-01-01", "2024-07-01") returns 0.5, meaning exactly half a year. This function is essential for financial calculations, age computations, and any scenario where you need precise year-based intervals.

What Is YEARFRAC and Why Does It Matter?

YEARFRAC stands for “year fraction.” Unlike simple date subtraction (which gives days) or the DATEDIF function (which gives whole units like months or years), YEARFRAC gives you a decimal value that represents the exact fraction of a year between two dates. This is crucial for pro-rating salaries, calculating accrued interest, determining depreciation schedules, or measuring tenure in years with precision. Without YEARFRAC, you’d have to manually divide day counts by 365 or 360, which is error-prone and inconsistent across different conventions.

YEARFRAC Syntax and Arguments

The syntax is: YEARFRAC(start_date, end_date, [day_count_convention])

  • start_date – The beginning date. Can be a cell reference, a date entered with DATE(), or a date string in quotes like "2024-01-01".
  • end_date – The ending date. Must be after start_date for a positive result; if reversed, YEARFRAC returns a negative value.
  • day_count_convention – Optional. A number that determines how days are counted. If omitted, Google Sheets defaults to 0 (US 30/360).

The valid convention codes are:

  • 0 or omitted – US (NASD) 30/360: Assumes 30-day months and 360-day years, with special rules for the 31st of a month.
  • 1 – Actual/actual: Uses the actual number of days in each month and year.
  • 2 – Actual/360: Uses actual days but assumes a 360-day year.
  • 3 – Actual/365: Uses actual days but assumes a 365-day year.
  • 4 – European 30/360: Like US 30/360, but the 31st is always treated as the 30th (no special February rule).

How to Use YEARFRAC in Real Spreadsheets

Let’s walk through a practical example. Suppose you have start dates in column A and end dates in column B, starting at row 2.

With dates in A2 and B2, the formula =YEARFRAC(A2, B2) returns the fraction using the default US 30/360 convention. For instance, if A2 is 2024-01-01 and B2 is 2024-12-31, the result is 0.997222 (not exactly 1, because 30/360 counts each month as 30 days, so 360 days total, but December 31 is treated as December 30, giving 359 days).

To get the actual/actual value, use =YEARFRAC(A2, B2, 1). For the same dates, this returns 0.997260 (365 days / 366 days in 2024, since 2024 is a leap year).

You can also embed dates directly: =YEARFRAC(DATE(2024,1,1), DATE(2024,6,30), 1) returns approximately 0.49589 (181 days / 365 days).

Choosing the Right Day Count Convention

The convention you choose dramatically affects results, so pick based on the context:

  • For financial bonds (especially US corporate bonds), the default 30/360 is standard.
  • For savings interest or short-term loans, Actual/360 is common in money markets.
  • For mortgages in many countries, Actual/365 is used.
  • For human age or general time spans, Actual/actual is most intuitive because it reflects real calendar days.

If you’re unsure, use 1 (actual/actual) for general purposes, as it gives the most accurate real-world fraction.

Common Errors and How to Fix Them

Here are typical mistakes users encounter:

  • #VALUE! error – Occurs if a date is not recognized. Ensure cells contain actual dates (formatted as dates) or valid date strings. Avoid text that looks like dates but isn’t.
  • #NUM! error – Happens if the day_count_convention is outside 0–4, or if start_date is after end_date (though this gives a negative number, not an error, in most cases).
  • Negative results – If start_date is later than end_date, YEARFRAC returns a negative fraction. To always get a positive, wrap with ABS() or sort your dates.
  • Unexpected rounding – Remember that 30/360 conventions don’t reflect actual calendar days. If you compare results to manual day counts, they will differ.

YEARFRAC vs. DATEDIF vs. Simple Subtraction

Google Sheets offers several date functions, and each serves a different purpose:

  • Simple subtraction (=B2-A2) returns the number of days between dates. It’s the raw count, no year conversion.
  • DATEDIF (=DATEDIF(A2, B2, "Y")) returns whole years, ignoring fractional parts. You can also get “M” for months or “D” for days, but it never gives a decimal year.
  • YEARFRAC gives the decimal year, which is the most precise for calculations that need continuous values, like prorated payments.

For example, from 2024-01-01 to 2025-06-15: subtraction gives 531 days, DATEDIF with “Y” gives 1 (whole year), and YEARFRAC with actual/actual gives approximately 1.45205. Only YEARFRAC captures the extra half-year.

YEARFRAC in Google Sheets vs. Excel

YEARFRAC works almost identically in Microsoft Excel, but there are minor differences:

  • In Excel, the default convention is also 0 (US 30/360), so results match.
  • Excel’s YEARFRAC may handle some edge cases (like February 29) slightly differently under actual/actual, but for most dates results are the same.
  • Google Sheets allows you to enter dates as strings directly in the formula; Excel also does, but it’s safer to use DATEVALUE or cell references.

If you’re migrating a spreadsheet from Excel to Sheets, YEARFRAC formulas will carry over without issue.

Frequently Asked Questions

Can YEARFRAC calculate age in years? Yes, you can use =YEARFRAC(birthdate, TODAY(), 1) to get a precise decimal age. For example, if someone was born on 2000-06-15 and today is 2025-01-01, the result is approximately 24.54. To display as whole years, wrap with INT().

What does the 30/360 convention mean exactly? It assumes every month has 30 days and every year has 360 days. The US version has a special rule: if the start date is the 31st, it becomes the 30th; if the end date is the 31st and the start date is the 30th or 31st, the end date becomes the 30th. This is used in bond markets to simplify interest calculations.

Why is my YEARFRAC result negative? That happens when start_date is after end_date. For example, =YEARFRAC(DATE(2024,12,31), DATE(2024,1,1)) returns a negative number. Double-check your date order.

Can I use YEARFRAC with times? Yes, but only the date part is considered; time components are ignored. If you need to include time, you’d have to add the fraction of a day manually.

Is there an alternative to YEARFRAC? You can calculate the fraction manually: =(B2-A2)/365 for a rough estimate, but this ignores leap years and conventions. For accuracy, YEARFRAC is the recommended function.

Does YEARFRAC work with text dates? Yes, if the text is a valid date format recognized by Google Sheets, like “2024-01-01”. However, it’s safer to use DATE() or cell references to avoid parsing issues.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.