This tutorial demonstrates how to use the YEARFRAC Function in Excel, Google Sheets, and VBA to return the fraction of the year between dates.

YEARFRAC Main function

YEARFRAC Function Overview

The YEARFRAC Function Returns the fraction of a year between two dates.

To use the YEARFRAC function, select a cell and type:

yearfrac formula syntax

(Notice how the formula input appear)

YEARFRAC Function Syntax and Inputs:

start_date – The start date

end_date – The end date

[basis] – [Optional] The basis that determines the number of days in the year.


Less Than One Year

Less Than One YearWhole Year

Whole YearMore than One Year

More than One Year


By default, Excel uses the US 30/360 basis, where a year is 360 days long and each month has 30 days. Instead you can change the basis:

YEARFRAC Basis Table

Here is the impact of changing the basis:

Different Basis

YEARFRAC in Google Sheets

The YEARFRAC Function works exactly the same in Google Sheets as in Excel:
YEARFRAC Google Sheet

YEARFRAC Examples in VBA

You can also use the YEARFRAC function in VBA. Type:
For the function arguments (start_date, etc.), you can either enter them directly into the function, or define variables to use instead.