Excel - YEARFRAC Function



YEARFRAC Function

The Excel YEARFRAC function transforms the interval between two dates into a year fraction. This function returns the decimal value representing the proportion of the year. It is part of the Date and Time functions in Excel. For instance, the YEARFRAC function can be used to evaluate the exact time estimation of government employee retirement, and it is also helpful in financial investments, savings, liabilities, etc.

Compatibility

This advanced Excel function is compatible with the following versions of MS-Excel −

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel 2024
  • Excel 2024 for Mac
  • Excel 2021
  • Excel 2021 for Mac
  • Excel 2019
  • Excel 2016
  • Excel 2013
  • Excel 2010
  • Excel 2007

Syntax

The syntax of the YEARFRAC function is as follows −

=YEARFRAC(start_date, end_date, [basis])

Arguments

You can use the following arguments with the YEARFRAC function −

Argument Description Required/ Optional
Start_date A serial number or Date that denotes the beginning date. Required
End_date Another serial number or Date that denotes the ending date Required
Basis

It specifies the day count basis type to be employed.

The Day Count Basis Table is specified below.

Optional

Day Count Basis Table

Basis Day Count Basis
0 or omitted US (NASD) 30/360
1 Actual/actual
2 Actual/360
3 Actual/365
4 European 30/360

Points to Remember

  • Microsoft Excel stores dates as sequential serial numbers so they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900
  • If the argument contains the decimal number, then it will be truncated to the integer value.
  • If valid dates are not specified in the arguments, then the YEARFRAC function will retrieve the #VALUE! error.
  • If the basis argument contains the non-numeric value, then the YEARFRAC function will return the #VALUE! error.
  • If the basis argument doesn't lie between 0 and 4, then the YEARFRAC function will return the #NUM! error.

Example of YEARFRAC Function

Practice the following example to learn the use of the YEARFRAC function in Excel.

What does the YEARFRAC Function do in Excel?

In this example, the serial numbers of the dates are displayed in the range of cells B3:B5. The task is to evaluate the YEARFRAC function between the Start and End dates.

Solution

Step 1 − First, you may select the cell range D3:D5 and enter the formula =YEARFRAC(B2,C2) in the formula bar.

What does YEARFRAC Function do in Excel1

Step 2 − After that, press the "Ctrl+Enter" to get the resulting value.

What does YEARFRAC Function do in Excel2

Therefore, the YEARFRAC function calculates the fraction of the year's total days between the Start and End Dates.

Step 3 − Furthermore, you may directly pass the Date serial number to the YEARFRAC function. Double-click on the C7 cell and type the formula "=YEARFRAC(42370,43560,4)". Here, the value of basis is 4.

What does YEARFRAC Function do in Excel3

Therefore, the YEARFAC returns the 3.2611.

Download Practice Sheet

You can download and use the sample data sheet to practice the YEARFRAC function.

Advertisements