Skip to Main Content Skip to Search
Product Documentation

yearfrac - Fraction of year between dates

Syntax

YearFraction = yearfrac(StartDate, EndDate, Basis) 

Arguments

StartDate

Enter as serial date numbers or date strings.

EndDate

Enter as serial date numbers or date strings.

Basis

(Optional) Day-count basis of the instrument. A vector of integers.

  • 0 = actual/actual (default)

  • 1 = 30/360 (SIA)

  • 2 = actual/360

  • 3 = actual/365

  • 4 = 30/360 (BMA)

  • 5 = 30/360 (ISDA)

  • 6 = 30/360 (European)

  • 7 = actual/365 (Japanese)

  • 8 = actual/actual (ICMA)

  • 9 = actual/360 (ICMA)

  • 10 = actual/365 (ICMA)

  • 11 = 30/360E (ICMA)

  • 12 = actual/actual (ISDA)

  • 13 = BUS/252

For more information, see basis.

All specified arguments must be number of instruments (NUMINST)-by-1 or 1-by-NUMINST conforming vectors or scalar arguments.

Description

YearFraction = yearfrac(StartDate, EndDate, Basis) returns a fraction based on the number of days between dates StartDate and EndDate using the given day-count basis. Note, the number of days in a year (365 or 366) is equal to the number of days in the calendar year after the StartDate. If EndDate is earlier than StartDate, Fraction is negative.

Examples

Compute yearfrac When the Calendar Year After the StartDate is Not a Leap Year

Given a Basis of 0 and a Basis of 1, compute yearfrac.

Define the StartDate and EndDate using a Basis of 0.

YearFraction = yearfrac('14 mar 01', '14 sep 01', 0)
YearFraction =

    0.5041

Define the StartDate and EndDate using a Basis of 1.

YearFraction = yearfrac('14 mar 01', '14 sep 01', 1)
YearFraction =

    0.5000

Compute yearfrac When the Calendar Year After the StartDate is a Leap Year

Given a Basis of 0, compute yearfrac when the calendar after StartDate is in a leap year.

Define the StartDate and EndDate using a Basis of 0.

yearFraction = yearfrac(' 14 mar 03', '14 sep 03', 0) 
yearFraction =

    0.5027

There are 184 days between March 14 and September 14, and the calendar year after the StartDate is a leap year, so yearfrac returns 184/366 = 0.5027.

See Also

days360 | days365 | daysact | daysdif | months | wrkdydif | year | yeardays

  


Free Interactive Computational Finance CD

View demos and recorded presentations led by industry experts.

Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS