Google Sheets Tips

YEAR and YEARFRAC functions in Google Sheets: get the year from a date and the years between two dates

YEAR returns the year of a date as a number. YEARFRAC returns the time between two dates in years, with decimals, by one of five day count conventions. This guide works both on a customer list to answer how long each customer has been with us: how to get the year from a date, how to count years between two dates, how to calculate age and tenure correctly, what each day count convention returns for the same dates, and the errors to expect.

Google Sheets TipsVadym Kramarenko11 min read

YEAR and YEARFRAC functions in Google Sheets: get the year from a date and the years between two dates

To get the year from a date, use YEAR:

=YEAR(B2)

With 3/14/2019 in B2, the formula returns 2019, as a number. To get the years between two dates, use YEARFRAC:

=YEARFRAC(B2, E2, 1)

It returns the time from the first date to the second in years, with decimals: 0.5 for half a year, 10 for ten years.

This guide works both functions on one question a CEO asks before a renewal round or a board meeting: how long has each customer been with us? The answer is one YEARFRAC formula per customer. On the customer list below, Northgate Outfitters has been with us for 7.63 years and Varga Hotels for 0.72; the seven active customers average 3.77 years, and the three who left stayed 2.27 years on average.

You need Formula
The year of a date =YEAR(B2)
The current year =YEAR(TODAY())
The year as text =TEXT(B2, "yyyy")
Years between two dates, with decimals =YEARFRAC(B2, E2, 1)
Whole years between two dates =DATEDIF(B2, E2, "Y")
Age in whole years =INT(YEARFRAC(B2, TODAY(), 1))

The customer list used here has ten customers, one per row, from row 2 to row 11, exported on 10/31/2026. That date sits in H2, so the numbers on this page stay fixed; in a live sheet, TODAY() takes its place.

Column Holds
A: Customer The account name
B: Customer since The date of the first paid order
C: Churned on The date the customer left; empty while the customer is active
D: Lifetime revenue Everything the customer has paid, in dollars
E: Tenure end =IF(C2="", $H$2, C2): the churn date, or the export date for an active customer
F: Tenure, years =YEARFRAC(B2, E2, 1)

Reading to get this done?

YEAR: get the year from a date

YEAR: get the year from a date

=YEAR(date)

  • date: a cell with a date, a function that returns a date, or a date serial number.

=YEAR(B2)

Copied down column G, it gives the year each customer was acquired: 2019 for Northgate Outfitters, 2026 for Varga Hotels. That year is the customer’s cohort.

The customer list in Google Sheets: customer, customer since, churned on and lifetime revenue for ten customers, with =YEAR(B2) in G2 returning the year each customer was acquired, from 2019 for Northgate Outfitters to 2026 for Varga Hotels

What YEAR accepts

  • A cell with a date: =YEAR(B3).
  • A function that returns a date: =YEAR(TODAY()), =YEAR(DATE(2024, 12, 31) + 1), which returns 2025.
  • A date in quotes: =YEAR("2024-03-15") returns 2024. A text such as “03/15/1985” is read according to the locale of the spreadsheet, so the ISO form, year-month-day, is the safe one to type.
  • A serial number: Google Sheets stores a date as the number of days since 30 December 1899. =YEAR(45000) returns 2023, =YEAR(28797) returns 1978.

The format of the cell does not matter, only the value. If Tidewater Labs’ first order arrives from the export as the plain number 45366 instead of 3/15/2024, =YEAR(B8) still returns 2024.

Group and sum by year

Add a helper column with =YEAR(B2) and build a pivot table on it, or total one cohort directly. The lifetime revenue of the customers acquired in 2023:

=SUMPRODUCT((YEAR(B2:B11) = 2023) * D2:D11)

It returns $58,900: Mosswood Retail and Pell Studio. The range must not include the header row: YEAR of a text is an error. In QUERY, the same grouping is SELECT year(B), sum(D) GROUP BY year(B).

A fiscal year that does not start in January

For a fiscal year that begins on 1 July and is named after the year in which it ends:

=IF(MONTH(B2) >= 7, YEAR(B2) + 1, YEAR(B2))

Pell Studio, a customer since 7/1/2023, lands in fiscal 2024, while YEAR says 2023.

Check the year of a date

=IF(YEAR(B2)=YEAR(DATE(2024,6,7)),"Yes","No")

On the customer list it returns Yes for the two customers acquired in 2024, Tidewater Labs and Orchard Dental, and No for the other eight. =IF(YEAR(B2) = 2024, "Yes", "No") does the same; the DATE version is useful when the date to compare with is in a cell.

YEARFRAC: years between two dates

YEARFRAC: years between two dates

=YEARFRAC(start_date, end_date, [day_count_convention])

  • start_date, end_date: the two dates. In our test the order did not matter: swapped dates returned the same positive number.
  • day_count_convention: optional, 0 to 4. How days and years are counted. The default is 0.

=YEARFRAC(B2, E2, 1)

With the customer since date in B and the tenure end in E, it returns each customer’s tenure in years. Formatted to two decimals: 7.63 for Northgate Outfitters, 4.66 for Halden Supply, which left on 6/30/2025, and 1.94 for Orchard Dental.

The customer list in Google Sheets with the tenure end in column E and =YEARFRAC(B2, E2, 1) in F2 returning each customer’s tenure in years, 7.63 for Northgate Outfitters and the shortest, 0.66, for Kestrel Logistics, with the export date 10/31/2026 in H2

The day count conventions

The convention decides how many days a month and a year have. The results below are for Mosswood Retail, a customer from 28 February 2023 to 31 August 2024: 550 days that include 29 February of the leap year 2024, checked in Google Sheets:

Convention Method Result
0 (default) US 30/360: every month has 30 days, the year 360 1.5
1 Actual/actual: real days, real length of the year 1.5050
2 Actual/360: real days, a year of 360 1.5278
3 Actual/365: real days, a year of 365 1.5068
4 European 30/360 1.5056

The default basis 0 counts 28 February, the last day of the month, as the 30th, and then 31 August as the 30th too, so the period is exactly 18 months of 30 days. The European method keeps 28 February as the 28th. The differences are small and they matter in finance, where the convention is part of the contract. For ages, tenures and anything about real calendar time, use 1.

Google Sheets with Mosswood Retail’s dates, 2/28/2023 to 8/31/2024, in five rows and =YEARFRAC(B2, C2, D2) with conventions 0 to 4 returning 1.5000, 1.5050, 1.5278, 1.5068 and 1.5056

One customer, one period, five slightly different results.

Interest for a part of a year

Interest for a period is the amount times the annual rate times the fraction of the year:

=D3 * E3 * YEARFRAC(B3, C3, 0)

on an invoices tab, with the start and end of the period in B3 and C3, the amount in D3 and the rate in E3 entered as a percentage, 5.5%. On a final invoice of $12,000 that Halden Supply paid late, overdue from 7/15/2025 to 10/31/2025, it returns $194.33. A rate typed as the plain number 5.5 has to be divided by 100, or the result is a hundred times too large: $19,433.33.

Hand this to your AI

Some ages in your sheet are a year off, because subtracting the years ignores whether the birthday has passed.

Paste this into your AI assistant. It writes the YEAR and YEARFRAC formulas for your date columns: ages and tenure in whole years, and totals by calendar or fiscal year.

The prompt

write me formulas for my sheet that calculate age or tenure in whole years from the date column and sum revenue by fiscal year, with the day count convention stated

Calculate age

Calculate age

A customer’s tenure is the same calculation as a person’s age.

The subtraction that is wrong half of the time

=YEAR(TODAY())-YEAR(B2)

This takes the difference in years between two dates by comparing the two years, and ignores the month and day. For someone whose birthday is still ahead this year, it returns one year too many. On the customer list, =YEAR(E2)-YEAR(B2) makes the same mistake three times: it gives Halden Supply 5 years for 4.66, Orchard Dental 2 years for 1.94, and Kestrel Logistics 1 year for 0.66.

Age with decimals

=YEARFRAC(B2,TODAY(),1)

It gives the years between a date and today; on the customer list, the tenure end takes the place of TODAY in column F.

Age in whole years

=INT(YEARFRAC(B2,TODAY(),1))

INT drops the decimals. In our test, for a date of birth of 15 June 1990, the formula returned 35 on 14 June 2026 and 36 on 15 June 2026, the same as =DATEDIF(B2, TODAY(), "Y"). On the customer list, =INT(YEARFRAC(B2, E2, 1)) and =DATEDIF(B2, E2, "Y") agree for all ten customers: Orchard Dental has 1 whole year, not the 2 the subtraction gives. DATEDIF is described in the guide to date functions; TODAY makes the result change by itself as time passes.

Where this shows up in a report

Where this shows up in a report

The CEO’s question takes one more formula. With the tenure in column F and column C empty for active customers, the average tenure of the customers who are still with us goes in one cell:

=AVERAGEIF(C2:C11, "", F2:F11)

The customer list in Google Sheets with tenure in column F and a summary in H4:I7: =AVERAGEIF(C2:C11, “”, F2:F11) in I4 returns 3.77 average years for active customers, 2.27 for churned customers, 4 active customers with 3 or more years and $423,450 of their lifetime revenue

It returns 3.77 years. The three customers who left stayed 2.27 years on average, =AVERAGEIF(C2:C11, "<>", F2:F11). Four of the seven active customers have been with us for three years or more, =COUNTIFS(C2:C11, "", F2:F11, ">=3"), and they hold $423,450 of the $470,000 the active customers have paid.

Each number is correct arithmetic for the rule it follows, and the rule is a business decision. Count the churned customers up to the export date, as if they had never left, and the average for all ten rises from 3.32 to 3.72 years: Halden Supply alone goes from 4.66 to 5.99. Use the year subtraction and three customers gain a year they have not had. So write the rule next to the number: “tenure from the first paid order to the churn date, or to 10/31/2026 for active customers”. The decision that follows sits next to it too: who renews the four long-standing accounts that carry most of the revenue, and why Mosswood Retail and Kestrel Logistics left before their second anniversary.

Errors and wrong results

Errors and wrong results

⚠️ Error: #VALUE!

✅ Solution: The value is a text that is not a date: =YEAR("abc"). Dates imported as text, often left-aligned in the cell, cause this. Convert them with DATEVALUE or rebuild them with DATE. See dates and times.

⚠️ Error: YEAR returns 1899.

✅ Solution: The cell is empty or holds 0. Day zero of the date system is 30 December 1899. Skip empty cells: =IF(C2 = "", "", YEAR(C2)).

⚠️ Error: The result looks like a date in 1905.

✅ Solution: The result cell is formatted as a date, and the number 2015 is shown as day 2015 of the date system. Set the format to Format > Number > Number or Automatic.

⚠️ Error: #NUM! in YEARFRAC.

✅ Solution: The convention is outside 0 to 4.

⚠️ Error: The wrong year from a typed date.

✅ Solution: “03/04/2024” is 4 March in one locale and 3 April in another. Type dates as DATE(2024, 3, 4) or “2024-03-04”.

⚠️ Error: YEARFRAC differs slightly from what was expected.

✅ Solution: The default convention counts 30-day months. Add 1 as the third argument for real days: for Mosswood Retail the default returns 1.5 and convention 1 returns 1.5050.

Related date functions

The year column should not depend on who built the report

The year column should not depend on who built the report

The formula is exact; the rows may not be. YEARFRAC counts correctly from whatever dates the sheet holds. If the customer export was pulled before the last cancellations were booked, a customer who left last week still counts as active until the next export, and the average tenure is measured against whatever was true on the day of the export. Calendar year or fiscal year, the first order or the first payment as the start of tenure: each report that derives these with its own helper column makes that choice again, and two reports on the same export can put the same customer into different years.

The OWOX Data Marts extension for Google Sheets covers that half. A data analyst publishes a Data Mart (a table or an SQL query in your data warehouse) with the definitions the team agreed, such as which date makes someone a customer and which one ends it, and makes it available for reports. In Sheets you open the extension, pick the Data Mart, tick the columns you want and run it. The rows land in a tab, ready for your formulas.

Google Sheets with the OWOX Data Marts extension open beside an ad spend table: the Unified Ad Spend Data Mart, nine of fourteen columns ticked and a Save & Run button – the rows in the sheet come from a governed Data Mart, not a pasted export

What changes for the person who maintains the sheet:

  • Refresh replaces re-export. Refresh current report in the extension menu re-runs the same pull, and a scheduled refresh keeps the tab current without anyone touching it.
  • The source is written on the sheet. The header cell of an imported tab carries a note with the Data Mart it came from, the time of the import and a link to the report.
  • No SQL and no data warehouse access needed. The analyst decides which Data Marts and columns are available. You choose from that list.

The extension does not write or change the analyst’s SQL. When the year, the fiscal period and the start and end of a customer’s tenure are defined once in that SQL, every report built on the Data Mart counts the same years, and YEAR and YEARFRAC are left for the quick question in a sheet. The extension comes with the OWOX Cloud plans of OWOX Data Marts; spreadsheet reporting describes both ways data reaches a sheet.

Hand this to your AI

Some ages in your sheet are a year off, because subtracting the years ignores whether the birthday has passed.

Paste this into your AI assistant. It writes the YEAR and YEARFRAC formulas for your date columns: ages and tenure in whole years, and totals by calendar or fiscal year.

The prompt

write me formulas for my sheet that calculate age or tenure in whole years from the date column and sum revenue by fiscal year, with the day count convention stated

FAQ

Frequently Asked Questions

How can I troubleshoot errors with YEAR or YEARFRAC?

#VALUE! means the value is a text that Sheets does not read as a date, such as a first-order date exported as text: convert it with DATEVALUE or rebuild it with DATE. A result of 1899 means the cell is empty or holds 0, as the empty Churned on cell of an active customer does; skip it with `=IF(C2="", "", YEAR(C2))`. #NUM! in YEARFRAC means the day count convention is outside 0 to 4. A year that looks like a date in 1905 means the result cell is formatted as a date; change the format to Number.

Can YEAR or YEARFRAC work with dates in different formats (e.g., "MM/DD/YYYY" vs. "YYYY-MM-DD")?

Yes. YEAR and YEARFRAC read the value of the cell, not its format, so 3/15/2024, 2024-03-15 and the serial number 45366 all return 2024 with YEAR. The risk is a date stored as text: "03/04/2024" is 4 March in one locale and 3 April in another, and a text Sheets cannot read returns #VALUE!. Type dates as DATE(2024, 3, 15) or in the ISO form, "2024-03-15", or convert imported text with DATEVALUE.

Can YEAR and YEARFRAC functions be combined with other functions?

Yes. On a customer list with the first order date in column B, `=SUMPRODUCT((YEAR(B2:B11) = 2023) * D2:D11)` totals the lifetime revenue of the customers acquired in 2023, and `=IF(MONTH(B2) >= 7, YEAR(B2) + 1, YEAR(B2))` gives a fiscal year that starts in July. With the tenure in column F, `=INT(YEARFRAC(B2, E2, 1))` returns whole years, and `=AVERAGEIF(C2:C11, "", F2:F11)` averages the tenure of the customers who have not churned: 3.77 years in the example.

Can the YEAR function handle non-date values?

A text that is not a date returns #VALUE!. A number is treated as a date serial number, so =YEAR(45000) returns 2023, and a first-order date that arrives from an export as 45366 still returns 2024. An empty cell counts as 0 and returns 1899, which is what YEAR gives for the empty churn date of an active customer. Check for empty cells with IF before applying YEAR.

When should I use YEARFRAC instead of YEAR?

Use YEARFRAC when you need the time between two dates, and YEAR when you need the calendar year of one date. Subtracting years ignores the month and day: for a customer since 11/20/2024, `=YEAR(E2)-YEAR(B2)` gives 2 years on 10/31/2026, while `=YEARFRAC(B2, E2, 1)` returns 1.94 and its whole part is 1. YEAR is the right tool for grouping customers into the year they were acquired.

How does the YEARFRAC function work in Google Sheets?

YEARFRAC returns the time between two dates in years, as a decimal. Its syntax is =YEARFRAC(start_date, end_date, [day_count_convention]). The optional third argument, 0 to 4, sets how days are counted: the default 0 assumes 30-day months and a 360-day year, and 1 uses the actual days and the actual length of the year. For a customer from 28 February 2023 to 31 August 2024, the default returns 1.5 and convention 1 returns 1.5050.

What does the YEAR function do in Google Sheets?

The YEAR function in Google Sheets extracts the year from a date and returns it as a four-digit number. With a customer's first order date, 3/14/2019, in B2, =YEAR(B2) returns 2019, the year the customer was acquired. Copied down a customer list, it gives each customer's cohort, which you can then total with SUMPRODUCT or group in a pivot table.

Who wrote this

Vadym Kramarenko

Vadym Kramarenko Growth Marketing Manager

Vadym Kramarenko is a Growth Marketing Manager at OWOX, where he drives user acquisition and product-led growth strategies. He hosts the OWOX podcast, interviewing analytics professionals about data-driven marketing, attribution, and reporting best practices. Vadym specializes in turning complex analytics concepts into practical, actionable marketing frameworks.