Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

busdays

Business days for given period

Syntax

bdates = busdays(sdate,edate)
bdates = busdays(___,bdmode,holvec)

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,holvec) 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 holvec 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 array
   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 serial date numbers, date character vectors, or datetime arrays.

Data Types: double | char | datetime

End date, specified as serial date numbers, date character vectors, or datetime arrays.

Data Types: double | char | 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 dates, specified as a vector in date character vector, serial date, or datetime array format. If you specify holvec, you must also supply the frequency bdmode. Using a holvec value of NaN uses a holiday list that has no dates.

Data Types: double | char | datetime

Output Arguments

collapse all

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

Introduced before R2006a

Was this topic helpful?