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 = 5×11 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 = 5×1 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

Version History

Introduced before R2006a

expand all