Excel YEARFRAC Function
Basic Description
The Excel Yearfrac function returns the fraction of a year that is represented by the number of whole days between two supplied dates.
The syntax of the function is :
Where the arguments are as follows:
| start_date | - | The start of the period (this date also is included in the calculation) | ||||||||||||
| end_date | - | The end of the period (this date is included in the calculation) | ||||||||||||
| [basis] | - |
An optional argument, which specifies the type of day count basis to be used Possible values of [basis] and their meanings are:
|
Note that Microsoft advises that you do not type dates directly into functions, as Excel may interpret text representations of dates differently, depending on the date interpretation settings on your computer. Therefore the start_date and end_date arguments for the Yearfrac function should be input as either:
- References to cells containing dates
- Dates returned from other functions or formulas
Yearfrac Function Examples
The spreadsheets below show examples of the Excel Yearfrac function used to calculate the year fraction between 1st January 2011 and 31st March 2011, using each of the different Day Count Basis types.
The formulas for the functions are shown in the spreadsheet on the left, and the results are shown in the spreadsheet on the right.
| Formulas: | Results: |
|
|
For further examples of the Excel Yearfrac function, see the Microsoft Office website
Yearfrac Function Errors
If you get an error from the Excel Yearfrac function, this is likely to be one of the following:
| #VALUE! | - | Occurs if the start_date or end_date arguments are not valid dates. |
| #NUM! | - | Occurs if the value of the supplied [basis] argument is less than 0 or greater than 4. |