Main Content

holidays

Holidays and nontrading days

Description

H = holidays returns a vector or datetime array corresponding to all holidays and nontrading days.

example

H = holidays(StartDate,EndDate) returns a vector or datetime array corresponding to the holidays and nontrading days between StartDate and EndDate, inclusive.

example

H = holidays(___,AltHolidays) returns a vector or datetime array corresponding to the alternate list of holidays and nontrading days.

example

Examples

collapse all

Create a vector of serial date numbers corresponding to all holidays and nontrading dates between a specified StartDate and EndDate:

H = holidays('jan 1 2001', 'jun 23 2001') 
H = 5×1

      730852
      730866
      730901
      730954
      730999

datestr(H)
ans = 5x11 char array
    '01-Jan-2001'
    '15-Jan-2001'
    '19-Feb-2001'
    '13-Apr-2001'
    '28-May-2001'

Alternatively, using a datetime array for StartDate and EndDate returns a datetime array for H.

H = holidays(datetime(2001,1,1),datetime(2001,6,23))
H = 5x1 datetime
   01-Jan-2001
   15-Jan-2001
   19-Feb-2001
   13-Apr-2001
   28-May-2001

Input Arguments

collapse all

Start date, specified using a scalar or vector using a datetime array, string array, or date character vectors.

To support existing code, holidays also accepts serial date numbers as inputs, but they are not recommended.

Data Types: char | string | datetime

End date, specified scalar or vector using a datetime array, string array, or date character vectors.

To support existing code, holidays also accepts serial date numbers as inputs, but they are not recommended.

Data Types: char | string | datetime

Alternate list of holidays and nontrading days, specified scalar or vector using a datetime array, string array, or date character vectors.

To support existing code, holidays also accepts serial date numbers as inputs, but they are not recommended.

Data Types: char | string | datetime

Output Arguments

collapse all

Dates corresponding to all holidays and nontrading days, returned as a vector or a datetime array of dates.

Note

If StartDate, EndDate, and AltHolidays are all either strings or date character vectors, H is returned as serial date numbers. Use the function datetime to convert serial date numbers to formatted datetime arrays. If either StartDate, EndDate, or AltHolidays are datetime arrays, H is returned as a datetime array.

More About

collapse all

holidays

The holidays function is based on a modern five-day workweek.

This function contains all holidays and special nontrading days for the New York Stock Exchange from January 1, 1885 to December 31, 2070.

Since the New York Stock Exchange was open on Saturdays before September 29, 1952, exact closures from 1885 to 2070 include Saturday trading days. To capture these dates, use the function nyseclosures. The results from holidays and nyseclosures are identical if the WorkWeekFormat in nyseclosures is 'Modern'.

Version History

Introduced before R2006a

expand all