isbusday
True for dates that are business days
Description
Examples
Determine If a Given Date Is a Business Day
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
Date
— Date being checked
datetime array | string array | date character vector
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
Holiday
— Holidays and nontrading-day dates
non-trading day vector is determined by the routine holidays
(default) | datetime array | string array | date character vector
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
— Weekend days
[1 0 0 0 0 0 1]
(Saturday and Sunday form the weekend) (default) | vector of length 7, containing 0
and 1
, where 1
indicates weekend days
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
Busday
— Logical true if a business day
logical 0
or 1
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 R2006aR2022b: Serial date numbers not recommended
Although isbusday
supports serial date numbers,
datetime
values are recommended instead. The
datetime
data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.
To convert serial date numbers or text to datetime
values, use the datetime
function. For example:
t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)
y = 2021
There are no plans to remove support for serial date number inputs.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)