The Excel YEARFRAC function returns a decimal value that represents fractional years between two dates. You can use YEARFRAC to do things like calculate age with a birthdate.
Syntax: =YEARFRAC (start_date, end_date, [basis])
The YEARFRAC function syntax has the following arguments:
- Start_date (required argument) – This is the start of the period. The function includes the start date in calculations.
- End_date (required argument) – This is the end of the period. The function also includes the end date in calculations.
- [basis] (optional argument) – Specifies the type of day count basis to be used.
Basis Day count basis 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4
Example: Let’s look at some Excel YEARFRAC function examples and explore how to use the YEARFRAC function as a worksheet function in Microsoft Excel:
Based on the Excel spreadsheet above, the following YEARFRAC examples would return:
- If the dates you are using are not working, input them with the DATE() function.
- #NUM! error – Occurs when the given basis argument is less than 0 or greater than 4.
- #VALUE! error – Occurs when:
- The start_date or end_date arguments are not valid dates.
- The given [basis] argument is non-numeric.