Documentation

This is machine translation

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

busdate

Next or previous business day

Syntax

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

Description

example

Busday = busdate(Date) returns the scalar, vector, or matrix of the next or previous business days, depending on the definition for Holiday.

example

Busday = busdate(Date,DirFlag,Holiday,Weekend). returns the scalar, vector, or matrix of the next or previous business days, depending on the optional input arguments, including Holiday.

If both Date and Holiday 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

collapse all

Determine the next business day when Date is a character vector.

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

      731037


ans =

05-Jul-2001

Indicate that Saturday is a business day by appropriately setting the Weekend argument. July 4, 2003 falls on a Friday. Use busdate to verify that Saturday, July 5, is actually a business day.

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

05-Jul-2003

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 = 

  datetime

   05-Jul-2001

Related Examples

Input Arguments

collapse all

Reference business date, specified as a scalar, vector, or matrix using serial date numbers, date character vectors, or datetime arrays.

Data Types: double | char | datetime

Business day convention, specified date character vector or cell array of date character vectors with values of follow, modifiedfollow, previous, or modifiedprevious.

Also, DirFlag can be a scalar, vector, or matrix of search directions, where Next is DIREC = 1 (default) or Previous is DIREC = -1.

Data Types: double | char | datetime

Holidays and nontrading-day dates, specified as vector.

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.)

Data Types: double | char | datetime

Weekend days, specified as a vector of length 7, containing 0 and 1, where 1 indicates weekend days and the first element of this vector corresponds to Sunday.

Data Types: double

Output Arguments

collapse all

Next or previous business day, returned as a scalar, vector, or matrix depending on the definition for Holiday. If Date is a datetime array, Busday returns a datetime array. Otherwise, Busday returns a serial date numbers.

See Also

|

Introduced before R2006a

Was this topic helpful?