Files
playbook/skills/tsl-api-reference/references/codegen/dotnet/datawarehouse/time.md
T
csh 9010829c6d feat(tsl-api-reference): expand and reorganize api catalog
Flatten builtin pages, add third-party and platform scopes, and import financial and data warehouse references.

Keep the existing generated index without rebuilding after signature normalization.
2026-08-10 18:26:24 +08:00

67 lines
1.7 KiB
Markdown

# 数据仓库 / 时间相关函数
## `firstDay(stock_id)`
声明:function
得到股票StockID的第一个交易日期,如果缺省参数,则表示当前股票的第一个交易日
| 参数 | 类型 | 说明 |
| ---------- | ------ | ------------------------ |
| `stock_id` | string | 字符串,股票代码。可省略 |
返回:datetime
### 示例
范例01:调用函数
```tsl
setsysparam(pn_stock(), 'SZ000002');
Return firstday(); // 33240(1991-01-02);
```
## `lastDay(stock_id)`
声明:function
得到股票StockID的最后一个交易日期,如果缺省参数,则表示当前股票的最后一个交易日
| 参数 | 类型 | 说明 |
| ---------- | ------ | ------------------------ |
| `stock_id` | string | 字符串,股票代码。可省略 |
返回:datetime
### 示例
范例01:调用函数
```tsl
setsysparam(pn_stock(), 'SZ000002');
return lastday(); // 40794 (2011-09-08)
```
## `tradeDays(begin_date, end_date)`
声明:function
得到当前股票在两个日期间的交易日数目。如果参数BeginDate和参数EndDate是同一天而且有交易则为1,如果之间无交易日则为0。 该模型与股票、周期相关。获取开始时间到截止时间的交易日(周期)数
| 参数 | 类型 | 说明 |
| ------------ | -------- | ----------------------- |
| `begin_date` | datetime | TDateTime类型,开始时间 |
| `end_date` | datetime | TDateTime类型,结束时间 |
返回:int
### 示例
范例01:调用函数
```tsl
setsysparam(pn_stock(), 'SZ000002');
return tradeDays(inttodate(20100101), inttodate(20101231));
// 输出:240
```