Get the fraction of a year between two dates
=YEARFRAC(start_date, end_date, [basis])
| Parameter | Description |
|---|---|
start_date |
The start date. |
end_date |
The end date. |
basis |
[optional] The type of day count basis to use (see below). |
YEARFRAC returns a decimal number representing years between two dates. For example:
=YEARFRAC("1-Jan-2019","1-Jan-2020") // returns 1
=YEARFRAC("1-Jan-2019","1-Jul-2020") // returns 1.5
=YEARFRAC("1-Jan-2019","1-Jan-2021") // returns 2
Although the generic syntax for YEARFRAC shows the start date followed by the end date, you can provide the dates in any order with the same result. F
=YEARFRAC("1-Jan-2000","1-Jan-2019") // returns 19
=YEARFRAC("1-Jan-2019","1-Jan-2000") // returns 19
With a start date in cell A1, and an end date in cell B1, the YEARFRAC will return years between the two dates as a decimal number:
=YEARFRAC(A1,B1) // years between two dates
To get a whole number only (not rounded), you can use the INT function like this:
=INT(YEARFRAC(A1,B1)) // whole number only, discard decimal
To get current age based on a birthdate, you can use a formula like this:
=INT(YEARFRAC(birthdate,TODAY())) // age from birthdate
To get the percentage of the current year complete, you can use YEARFRAC like this:
=YEARFRAC(DATE(YEAR(TODAY()),1,1),TODAY()) // % year complete