How to Use the YEARFRAC Function in Excel

This document provides a comprehensive explanation of how to use the YEARFRAC function in both Microsoft Excel and Google Sheets. This function is designed to calculate the portion of the year expressed as the total number of whole days between two specified dates.

Basic Syntax

The syntax for the YEARFRAC function is consistent across both Excel and Google Sheets:

YEARFRAC(start_date, end_date, [basis])
  • start_date: The initial date of the period for which you wish to calculate the year fraction.
  • end_date: The final date of the period for which you wish to calculate the year fraction.
  • basis (optional): This parameter defines the day count convention to be used in the calculation. If not specified, the default value is 0.

Practical Examples

Calculating Age

Consider a scenario where you have a list of birth dates in column A and you need to determine each person’s age as of today’s date employing the YEARFRAC function:

Birth Date Age
A2: 01/15/1990 =YEARFRAC(A2, TODAY(), 1) * 100

Proportional Investment Return

Suppose you invested in a fund on March 15, 2020, and sold your shares on November 20, 2021. You aim to quantify the proportion of the year during which the investment was held:

Investment Start Investment End Days Held Proportional Time Held
B2: 03/15/2020 C2: 11/20/2021 =DAYS(C2, B2) =YEARFRAC(B2, C2, 1)

The YEARFRAC function is highly adaptable and can be effectively utilized in a variety of scenarios that require calculations based on dates.

More information: https://support.microsoft.com/en-us/office/yearfrac-function-3844141e-c76d-4143-82b6-208454ddc6a8

Other functions
Returns the serial number of a particular date
Calculates the number of days, months, or years between two dates This function is useful in formulas where you need to calculate an age
Converts a date in the form of text to a serial number
Converts a serial number to a day of the month
Returns the number of days between two dates
Calculates the number of days between two dates based on a 360-day year
Returns the serial number of the date that is the indicated number of months before or after the start date
Returns the serial number of the last day of the month before or after a specified number of months
Converts a serial number to an hour
Returns the number of the ISO week number of the year for a given date
Converts a serial number to a minute
Converts a serial number to a month
Returns the number of whole workdays between two dates
Returns the number of whole workdays between two dates using parameters to indicate which and how many days are weekend days
Returns the serial number of the current date and time
Converts a serial number to a second
Returns the serial number of a particular time
Converts a time in the form of text to a serial number
Returns the serial number of today's date
Converts a serial number to a day of the week
Converts a serial number to a number representing where the week falls numerically with a year
Returns the serial number of the date before or after a specified number of workdays
Returns the serial number of the date before or after a specified number of workdays using parameters to indicate which and how many days are weekend days
Converts a serial number to a year