The YEARFRAC function takes two dates and returns the number of years, including fractions of a year, between them. You can optionally specify different methods of counting days. Remember that dates are really justsaved as numbersby your spreadsheet with date formatting applied. The date must be in avalid format, so you have to use theDATE function, wrap it in quotes, or use a cell reference to a cell containing a date.

Syntax

=YEARFRAC(start_date,end_date,[day_count_convention])

  • start_date- The date for the calculation to start on.
  • end_date- The date for the calculation to end on.
  • day_count_convention- Optional indication of day count method to use.
    • 0 [or blank] - US (NASD) 30/360
    • 1 - actual/actual Uses the actual number of days.
    • 2 - actual/360 Uses the actual number of days but with a 360 day year.
    • 3 - actual/365 Uses the actual number of days but assumes a 365 day year. Doesn't recognize leap year.
    • 4 - European 30/360 Similar to 0 but uses European standards instead of US.

Related functions

DATE- Takes separate year, month, and day values and returns them as a date

DATEVALUE- Returns the serial value of a date

DAY- Returns the value the day from a given date

DAYS360- Calculates interest using the 360 method

Errors

#NUM- An input is a number but is not a valid date. This could happen if you used the 35th day of November.

#VALUE!- The input is something that doesn't convert to a number such as "The other day" or "Yester-yester-day".

Examples

 Live examples in Sheets 

Go tothis spreadsheetfor the examples of the YEARFRAC function shown above that you can study and use anywhere you would like.