Financial Toolbox | ![]() ![]() |
Determining Dates
The toolbox provides many functions for determining specific dates, including functions which account for holidays and other nontrading days.
For example, you schedule an accounting procedure for the last Friday of every month. The lweekdate
function returns those dates for 2000; the 6 specifies Friday.
Fridates = lweekdate(6, 2000, 1:12); Fridays = datestr(Fridates) Fridays = 28-Jan-2000 25-Feb-2000 31-Mar-2000 28-Apr-2000 26-May-2000 30-Jun-2000 28-Jul-2000 25-Aug-2000 29-Sep-2000 27-Oct-2000 24-Nov-2000 29-Dec-2000
Or your company closes on Martin Luther King Jr. Day, which is the third Monday in January. The nweekdate
function determines those dates for 2001 through 2004.
MLKDates = nweekdate(3, 2, 2001:2004, 1); MLKDays = datestr(MLKDates) MLKDays = 15-Jan-2001 21-Jan-2002 20-Jan-2003 19-Jan-2004
Accounting for holidays and other nontrading days is important when examining financial dates. The toolbox provides the holidays
function, which contains holidays and special nontrading days for the New York Stock Exchange between 1950 and 2030, inclusive. You can edit the holidays.m
file to customize it with your own holidays and nontrading days. In this example, use it to determine the standard holidays in the last half of 2000.
LHHDates = holidays('1-Jul-2000', '31-Dec-2000'); LHHDays = datestr(LHHDates) LHHDays = 04-Jul-2000 04-Sep-2000 23-Nov-2000 25-Dec-2000
Now use the toolbox busdate
function to determine the next business day after these holidays.
LHNextDates = busdate(LHHDates); LHNextDays = datestr(LHNextDates) LHNextDays = 05-Jul-2000 05-Sep-2000 24-Nov-2000 26-Dec-2000
The toolbox also provides the cfdates
function to determine cash-flow dates for securities with periodic payments. This function accounts for the coupons per year, the day-count basis, and the end-of-month rule. For example, to determine the cash-flow dates for a security that pays four coupons per year on the last day of the month, on an actual/365 day-count basis, just enter the settlement date, the maturity date, and the parameters.
PayDates = cfdates('14-Mar-2000', '30-Nov-2001', 4, 3, 1); PayDays = datestr(PayDates) PayDays = 31-May-2000 31-Aug-2000 30-Nov-2000 28-Feb-2001 31-May-2001 31-Aug-2001 30-Nov-2001
![]() | Current Date and Time | Formatting Currency | ![]() |