Main Content

isbusday

True for dates that are business days

Description

Busday = isbusday(Date) returns logical true (1) if Date is a business day and logical false (0) otherwise.

example

Busday = isbusday(___,Holiday,Weekend), using optional input arguments, returns logical true (1) if Date is a business day, and logical false (0) otherwise.

example

Examples

collapse all

Determine if Date is a business day.

Busday = isbusday('16 jun 2001')
Busday = logical
   0

Determine if a Date vector are business days.

Date = ['15 feb 2001'; '16 feb 2001'; '17 feb 2001'];
Busday = isbusday(Date)
Busday = 3x1 logical array

   1
   1
   0

Determine if a Date vector are business days using a datetime array.

Date = [datetime(2001,2,15); datetime(2001,2,16) ; datetime(2001,2,17)];
Busday = isbusday(Date)
Busday = 3x1 logical array

   1
   1
   0

Set June 21, 2003 (a Saturday) as a business day.

Weekend = [1 0 0 0 0 0 0];
isbusday(datetime(2003,6,21), [], Weekend)
ans = logical
   1

If the second argument, Holiday, is empty ([ ]), the default Holidays vector (generated with holidays and then associated to the NYSE calendar) is used.

Input Arguments

collapse all

Date being checked, specified as a scalar or a vector using a datetime array, string array, or date character vectors. Date can contain multiple dates, but they must all be in the same format. Dates are assumed to be whole date numbers or date stamps with no fractional or time values.

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

Data Types: char | string | datetime

Holidays and nontrading-day dates, specified as a vector using a datetime array, string array, or date character vectors.

All dates in Holiday must be the same format: either datetimes, strings, date character vectors, or serial date numbers. The holidays function supplies the default vector.

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

Data Types: char | string | 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

Logical true if a business day, returned as a logical true (1) if Date is a business day and logical false (0) otherwise.

Version History

Introduced before R2006a

expand all