YEARFRAC Function – Fraction of Year – Excel, VBA, G Sheets
Written by
Reviewed by
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 Examples
Less Than One Year
=YEARFRAC(B3,C3)
Whole Year
=YEARFRAC(B3,C3)
More than One Year
=YEARFRAC(B3,C3)
YEARFRAC Basis
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:
Here is the impact of changing the basis:
YEARFRAC in Google Sheets
The YEARFRAC Function works exactly the same in Google Sheets as in Excel:
YEARFRAC Examples in VBA
You can also use the YEARFRAC function in VBA. Type:
application.worksheetfunction.yearfrac(start_date,end_date,basis)
For the function arguments (start_date, etc.), you can either enter them directly into the function, or define variables to use instead.