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.

fbusdate

First business date of month

Syntax

  • Date = fbusdate(Year,Month)
    example
  • Date = fbusdate(Year,Month,Holiday,Weekend,outputType)
    example

Description

example

Date = fbusdate(Year,Month) returns the serial date number for the first business date of the given year and month.

Year and Month can contain multiple values. If one contains multiple values, the other must contain the same number of values or a single value that applies to all. For example, ifYear is a 1-by-N vector of integers, then Month must be a 1-by-N vector of integers or a single integer.Date is then a 1-by-N vector of date numbers.

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

example

Date = fbusdate(Year,Month,Holiday,Weekend,outputType) returns the serial date number for the first business date of the given year and month using optional input arguments. Holiday specifies nontrading days.

If neither Holiday or outputType are specified, Date is returned as a serial date number. If Holiday is specified, but not outputType, then the type of the holiday variable controls the type of date. If Holiday is a serial date number or date character vector, then Date is returned as a serial date number.

Examples

collapse all

This example shows how to return serial date numbers for the first business date, given year and month.

Date = fbusdate(2001, 11)
datestr(Date)

Year = [2002 2003 2004];
Date = fbusdate(Year, 11)
datestr(Date)
Date =

      731156


ans =

01-Nov-2001


Date =

      731521      731888      732252


ans =

01-Nov-2002
03-Nov-2003
01-Nov-2004

This example shows how to return serial date numbers for the first business date, given year and month, and also indicate that Saturday is a business day by setting the Weekend argument. March 1, 2003, is a Saturday. Use fbusdate to check that this Saturday is actually the first business day of the month.

Weekend = [1 0 0 0 0 0 0];
Date = datestr(fbusdate(2003, 3, [], Weekend))
Date =

01-Mar-2003

This example shows how to return a datetime array for Date using an outputType of 'datetime'.

Date = fbusdate(2001, 11,[],[],'datetime')
Date = 

  datetime

   01-Nov-2001

Related Examples

Input Arguments

collapse all

Year to determine occurrence of weekday, specified as a 4-digit integer or vector of 4-digit integers.

Data Types: single | double

Month to determine occurrence of weekday, specified as an integer or vector of integers with values 1 through 12.

Data Types: single | double

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.) The holidays function supplies the default vector.

If Holiday is a datetime array, then Date is returned as a datetime array. If outputType is specified, then its value determines the output type of Date. This overrides any influence of Holiday.

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

A character vector specified as either 'datenum' or 'datetime'. The output Date is in serial date format if 'datenum' is specified, or datetime format if 'datetime' is specified. By default the output Date is in serial date format,or match the format of Holiday, if specified.

Data Types: char

Output Arguments

collapse all

Date for the first business date of a given year and month, returned as a serial date number, date character vector, or datetime array.

If neither Holiday or outputType are specified, Date is returned as a serial date number. If Holiday is specified, but not outputType, then the type of the holiday variable controls the type of date:

  • If Holiday is a serial date number or date character vector, then Date is returned as a serial date number

  • If Holiday is a datetime array, then Date is returned as a datetime array.

.

Introduced before R2006a

Was this topic helpful?