YEARFRAC Function – Fraction of Year – Excel, VBA, G Sheets

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on November 6, 2023
Download Example Workbook

Download the example workbook

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


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.

AI Formula Generator

Try for Free

Excel Practice Worksheet

practice excel worksheet

Practice Excel functions and formulas with our 100% free practice worksheets!

  • Automatically Graded Exercises
  • Learn Excel, Inside Excel!

Free Download

Return to List of Excel Functions