Main Content

busdays

Business days for given period

Description

example

bdates = busdays(sdate,edate) generates a vector of business days between the last business date of the period that contains the start date (sdate), and the last business date of period that contains the end date (edate).

example

bdates = busdays(___,bdmode,Holiday) generates a vector of business days between the last business date of the period that contains the start date (sdate), and the last business date of period that contains the end date (edate) using optional input arguments. If Holiday is not supplied, the dates are generated based on United States holidays. If you do not supply bdmode, bdates generates a daily vector.

Examples

collapse all

Determine the business days for a weekly period.

 bdates = datestr(busdays('1/2/01','1/9/01','weekly'))
bdates = 2x11 char array
    '05-Jan-2001'
    '12-Jan-2001'

The end of the week is considered to be a Friday. Between 1/2/01 (Monday) and 1/9/01 (Tuesday), there is only one end-of-week day, 1/5/01 (Friday). Because 1/9/01 is part of the following week, the following Friday (1/12/01) is also reported.

Determine the business days for a weekly period using a datetime input for sdate.

bdates = busdays(datetime('2-Jan-2001','Locale','en_US'),'9-Jan-2001','weekly')
bdates = 2x1 datetime
   05-Jan-2001
   12-Jan-2001

Determine the business days for a monthly period.

vec = datestr(busdays('1/8/16','3/1/16','monthly'))
vec = 3x11 char array
    '29-Jan-2016'
    '29-Feb-2016'
    '31-Mar-2016'

The start date (1/8/16) is in the month of January, 2016. The last business day for the month of January is 1/29/16 (Friday). The end date (3/1/16) is in the month of March, 2016. The last business day for the month of March is 3/31/16 (Thursday). The month of February, 2016 lies between the start date and the end date. The last business day for the month of February is 2/29/16 (Monday).

Input Arguments

collapse all

Start date, specified as a scalar datetime, string, or date character vector.

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

Data Types: char | string | datetime

End date, specified as a scalar datetime, string, or date character vector.

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

Data Types: char | string | datetime

Frequency of business days, specified as a nonnegative numeric with values 1 through 5 or date character vector with values of DAILY, WEEKLY, MONTHLY, QUARTERLY, SEMIANNUAL, or ANNUAL

Valid periodicities include:

  • DAILY, Daily, daily, D, d, 1 (default)

  • WEEKLY, Weekly, weekly, W, w, 2

  • MONTHLY, Monthly, monthly, M, m, 3

  • QUARTERLY, Quarterly, quarterly, Q, q, 4

  • SEMIANNUAL, Semiannual, semiannual, S, s, 5

  • ANNUAL, Annual, annual, A, a, 6

    Character vectors must be enclosed in single quotation marks.

For example, if bdmode is set to monthly, busdays returns end-of-month business dates for all full or partial months between the start date and end date inclusive.

Data Types: double | char

Holiday and nontrading-day dates, specified as a vector using a datetime array, string array, or date character vectors. If you specify Holiday, you must also supply the frequency bdmode. Using a Holiday value of NaN uses a holiday list that has no dates.

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

Data Types: char | string | datetime

Output Arguments

collapse all

Business days, returned as a column vector of business dates, in datetime format (if sdate, edate, or Holiday are in datetime format). Business dates can exist before and/or after the specified sdate and edate.

Version History

Introduced before R2006a

expand all