zclllyybb commented on code in PR #2804:
URL: https://github.com/apache/doris-website/pull/2804#discussion_r2374700282
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/day-ceil.md:
##########
@@ -7,39 +7,133 @@
## 描述
-将日期转化为指定的时间间隔周期的最近向上取整时刻。
+DAY_CEIL 函数用于将指定的日期或时间值向上取整(ceil)到最近的指定天数周期的起点。即返回不小于输入日期时间的最小周期时刻,周期规则由
period(周期天数)和 origin(起始基准时间)共同定义。若未指定起始基准时间,默认以 0001-01-01 00:00:00 为基准计算。
+
+日期计算公式
+$$
+\text{DAY\_CEIL}(\langle\text{date\_or\_time\_expr}\rangle,
\langle\text{period}\rangle, \langle\text{origin}\rangle) =
\min\{\langle\text{origin}\rangle + k \times \langle\text{period}\rangle \times
\text{day} \mid k \in \mathbb{Z} \land \langle\text{origin}\rangle + k \times
\langle\text{period}\rangle \times \text{day} \geq
\langle\text{date\_or\_time\_expr}\rangle\}
+$$
+K 代表基准时间到达目标时间所需的周期数
## 语法
```sql
-DAY_CEIL(<datetime>)
-DAY_CEIL(<datetime>, <origin>)
-DAY_CEIL(<datetime>, <period>)
-DAY_CEIL(<datetime>, <period>, <origin>)
+DAY_CEIL(<date_or_time_expr>)
+DAY_CEIL(<date_or_time_expr>, <origin>)
+DAY_CEIL(<date_or_time_expr>, <period>)
+DAY_CEIL(<date_or_time_expr>, <period>, <origin>)
```
## 参数
| 参数 | 说明 |
| -- | -- |
-| `<datetime>` | 合法的日期表达式 |
-| `<period>` | 参数是指定每个周期有多少天组成 |
-| `<origin>` | 开始的时间起点,如果不填,默认是 0001-01-01T00:00:00 |
+| `<date_or_time_expr>` | 参数是合法的日期表达式,支持输入 date/datetime 类型,具体 datetime 和 date
格式请查看 [datetime
的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion)
和 [date
的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/date-conversion)
|
+| `<period>` | 参数是指定每个周期包含的天数,类型为 INT。若未指定,默认周期为 1 天。 |
+| `<origin>` | 参数是周期计算的起始基准时间,支持 date/datetime 类型|
## 返回值
-返回最近向上取整时刻的日期。
+返回的是一个日期或时间值,表示将输入值向上舍入到指定天数周期的结果。
+
+若输入有效,返回与 datetime 类型一致的取整结果:
+
+`<date_or_time_expr>` 与 `<origin>` 输入都 DATE 类型时,返回 DATE 类型, 否则返回 DATETIME 类型.
+
+特殊情况:
+
+- 任何参数为 NULL 时,返回 NULL;
+- 若 period 为负数或 0,返回错误;
+- 若取整结果超出日期类型支持的范围(如 '9999-12-31' 之后),报错。
+- 带有 scale 的输入的datetime,输出会截断所有 scale 为0 ,返回值带有 scale
Review Comment:
这个描述不妥当,scale没有变为0,是小数部分变为0了。不用特地描述
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]