<< Go back to all functions

YEARFRAC

The YEARFRAC function in Google Sheets calculates the number of years, including fractional years, between two dates using a specified day count convention. This versatile function is helpful for various applications, such as financial analysis, project planning, and determining the length of relationships.

Function Syntax and Parameters

Syntax: YEARFRAC(start_date, end_date, [day_count_convention])

Parameters:

  • start_date: The starting date.
  • end_date: The ending date.
  • [day_count_convention]: [Optional] The day count convention to use. If omitted, it defaults to 0 (US/NASD).

Step-by-Step Tutorial

  1. Calculating the number of years between two dates:

    • Syntax: =YEARFRAC(A1, B1)
    • Example:
      • If A1 has the value 01/01/2020 and B1 has the value 12/31/2021, then =YEARFRAC(A1, B1) will return 1.997267759.
      • If A1 has the value 01/01/2000 and B1 has the value 01/01/2022, then =YEARFRAC(A1, B1) will return 22.
  2. Using a specific day count convention:

    • Syntax: =YEARFRAC(A1, B1, 2)
    • Example:
      • If A1 has the value 01/01/2020 and B1 has the value 12/31/2021, then =YEARFRAC(A1, B1, 2) will return 1.991780822.

Use Cases and Scenarios

  1. Financial Analysis: Calculate the length of an investment.
  2. Project Planning: Determine the duration of a project.
  3. Relationship Length: Measure the time spent in a relationship.

Related Functions

  • DATEDIF: Calculate the difference between two dates in various units.
  • NOW: Get the current date and time.

Related Articles