businessDay
Syntax
businessDay(X, [offset], [n=1])
Details
If X is a business day (Monday to Friday), return date(X). Otherwise, return the most recent business day.
When both offset and n are specified and n > 1, the function calculates dates based on periods consisting of n business days. In this case, offset determines how the business-day periods are aligned. Specifically, the system first calculates the business day corresponding to offset and uses that day as the reference point. A new period boundary is then generated every n business days, and the function returns the business day corresponding to the period to which X belongs.
DolphinDB and pandas both provide similar date offset functionality at the conceptual level. For a comparison of calculation rules, see Functions Related to Date Offset.
Parameters
X is a scalar/vector of data type DATE, DATEHOUR, DATETIME, TIMESTAMP or NANOTIMESTAMP.
offset (optional) is a scalar of the same data type as X. It must be no greater than the minimum value of X. The default value is the minimum value of X.
n (optional) is a positive integer. The default value is 1.
Returns
A scalar/vector of type DATE.
Examples
businessDay(2019.01.06);
// output: 2019.01.04
businessDay(2019.01.04);
// output: 2019.01.04
date=2019.01.06 + 1..10
businessDay = businessDay(date)
businessDay2 = businessDay(date,min(date),2)
table(date, businessDay, businessDay2);
| date | businessDay | businessDay2 |
|---|---|---|
| 2019.01.07 | 2019.01.07 | 2019.01.07 |
| 2019.01.08 | 2019.01.08 | 2019.01.07 |
| 2019.01.09 | 2019.01.09 | 2019.01.09 |
| 2019.01.10 | 2019.01.10 | 2019.01.09 |
| 2019.01.11 | 2019.01.11 | 2019.01.11 |
| 2019.01.12 | 2019.01.11 | 2019.01.11 |
| 2019.01.13 | 2019.01.11 | 2019.01.11 |
| 2019.01.14 | 2019.01.14 | 2019.01.11 |
| 2019.01.15 | 2019.01.15 | 2019.01.15 |
| 2019.01.16 | 2019.01.16 | 2019.01.15 |
