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
-
Calculating the number of years between two dates:
- Syntax:
=YEARFRAC(A1, B1)
- Example:
- If
A1
has the value01/01/2020
andB1
has the value12/31/2021
, then=YEARFRAC(A1, B1)
will return1.997267759
. - If
A1
has the value01/01/2000
andB1
has the value01/01/2022
, then=YEARFRAC(A1, B1)
will return22
.
- If
- Syntax:
-
Using a specific day count convention:
- Syntax:
=YEARFRAC(A1, B1, 2)
- Example:
- If
A1
has the value01/01/2020
andB1
has the value12/31/2021
, then=YEARFRAC(A1, B1, 2)
will return1.991780822
.
- If
- Syntax:
Use Cases and Scenarios
- Financial Analysis: Calculate the length of an investment.
- Project Planning: Determine the duration of a project.
- 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.