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.

datewrkdy

Date of future or past workday

Syntax

  • EndDate = datewrkdy(StartDate,NumberWorkDays,NumberHolidays)
    example

Description

example

EndDate = datewrkdy(StartDate,NumberWorkDays,NumberHolidays)

returns the serial number of the date a given number of workdays before or after the start date.

Any input can contain multiple values, but if so, all other inputs must contain the same number of values or a single value that applies to all. For example, ifStartDate is an n-row character array of date character vectors, then NumberWorkDays must be an N-by-1 vector of integers or a single integer. EndDate is then an N-by-1 vector of date numbers.

If StartDate is a serial date number or date character vector, EndDate is returned as a date number. Use datestr to convert serial date numbers to formatted date character vectors.

If StartDate is a datetime array, then EndDate is returned as a datetime array.

Examples

collapse all

Determine the EndDate for a future workday using a date character vector for StartDate.

StartDate = '20-Dec-1994';
NumberWorkDays = 16;
NumberHolidays = 2;

EndDate = datewrkdy(StartDate, NumberWorkDays, NumberHolidays)
datestr(EndDate)
EndDate =

      728671


ans =

12-Jan-1995

Determine the EndDate for a future workday using a datetime array for StartDate.

EndDate = datewrkdy(datetime('12-dec-2000','Locale','en_US'), 16, 2)
EndDate = 

  datetime

   04-Jan-2001

Determine the EndDate for future workdays using a vector for NumberWorkDays.

NumberWorkDays = [16; 20; 44];
EndDate = datewrkdy('12-dec-2000', NumberWorkDays, 2);
datestr(EndDate)
ans =

04-Jan-2001
10-Jan-2001
13-Feb-2001

Related Examples

Input Arguments

collapse all

Start date, specified as an N-by-1 or 1-by-N vector using serial date numbers, date character vectors, or datetime arrays.

Data Types: double | char | datetime

Number of work or business days in future (positive) or past (negative) that includes the starting date, specified as an N-by-1 or 1-by-N vector containing positive or negative integers.

NumberHolidays and NumberWorkDays must have the same sign.

Data Types: double

Number of holidays within NumberWorkDays, specified as positive or negative integers using an N-by-1 or 1-by-N containing values for the number of days movement in terms of holidays into the future (if positive) or past (if negative).

NumberHolidays and NumberWorkDays must have the same sign.

Data Types: double

Output Arguments

collapse all

Date of future or past workday, returned as an N-by-1 or 1-by-N vector containing the serial date number (default) or the datetime (if StartDate is a datetime array) of the future or past date.

Introduced before R2006a

Was this topic helpful?