Documentation

busdate

Next or previous business day

Syntax

Busday = busdate(Date, DirFlag, Holiday, Weekend)

Arguments

Date

Reference date. Enter scalar, vector, or matrix of reference business dates as serial date numbers, date character vectors, or datetime arrays.

DirFlag

(Optional) Character vector or cell array of character vectors of business day convention with possible values: follow (default), modifiedfollow, previous, modifiedprevious. Also, DirFlag can be a scalar, vector, or matrix of search directions, where Next is DIREC = 1 (default) or Previous is DIREC = -1.

Holiday

(Optional) Vector of holidays and nontrading-day dates. All dates in Holiday must be the same format: either serial date numbers or date character vectors or datetime arrays. (Using serial date numbers improves performance.) If Holiday is not specified, the non-trading day default vector is determined by the routine holidays function.

Weekend

(Optional) Vector of length 7, containing 0 and 1, the value 1 indicating weekend days. The first element of this vector corresponds to Sunday. Thus, when Saturday and Sunday form the weekend (default), Weekend = [1 0 0 0 0 0 1].

Description

Busday = busdate(Date, DirFlag, Holiday, Weekend) returns the scalar, vector, or matrix of the next or previous business day(s), depending on Holiday.

If both Date and Holidays are either serial date numbers or date character vectors, Busday is returned as a serial date number.

However, if either Date or Holiday are datetime arrays, Busday is returned as a datetime array.

Use the function datestr to convert serial date numbers to formatted date character vectors.

Examples

Example 1.

Busday = busdate('3-Jul-2001', 1)
Busday =

     731037
datestr(Busday)
ans =

05-Jul-2001

Example 2. You can indicate that Saturday is a business day by appropriately setting the Weekend argument.

Weekend = [1 0 0 0 0 0 0];

July 4, 2003 falls on a Friday. Use busdate to verify that Saturday, July 5, is actually a business day.

Date = datestr(busdate('3-Jul-2003', 1, [], Weekend))

Example 3. If either Date or Holiday are datetime arrays, Busday is returned as a datetime array.

Busday = busdate(datetime('3-Jul-2001','Locale','en_US'), 1)
Busday = 

   05-Jul-2001

Related Examples

See Also

|

Introduced before R2006a

Was this topic helpful?