zclllyybb commented on code in PR #2819:
URL: https://github.com/apache/doris-website/pull/2819#discussion_r2346972032
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md:
##########
@@ -1,34 +1,35 @@
---
{
- "title": "TO_DAYS",
- "language": "zh-CN"
+ "title": "TO_DAYS",
+ "language": "zh-CN"
}
---
## 描述
日期计算函数,它用于将日期转换为天数数值,即计算从公元 0 年 12 月 31 日(基准日期)到指定日期的总天数。
Review Comment:
不存在公元0年
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/unix-timestamp.md:
##########
@@ -34,22 +53,30 @@ UNIX_TIMESTAMP([DATETIME date[, STRING fmt]])
## 返回值
根据输入返回两种类型
-1.若是输入的 `date` (只有 datetime 类型才可以有 scale 不为零) scale 不为 0 或者带有 `format` 参数
+1.若是输入的 date 为 datetime 类型且 scale 不为零或者带有 format 参数
返回一个时间戳,类型为 Decimal,最高六位小数精度
-2.若是输入的 `date` scale 为 0 并且不带有 `format` 参数
+2.若是输入的 date 或 scale 为 0 并且不带有 format 参数
返回一个时间戳,类型为 INT
-支持的输入范围为 '1970-01-01 00:00:00.000000 UTC' 至 '9999-12-31 23:59:59.999999
UTC'。早于最小值的时间返回 0。
+基于 UTC 时区的1970-01-01 00:00:01.000000 的秒数,将输入时间转换为当前机器所在时区所对应的时间戳.
+若输入带有时区,则返回基于 UTC 时区的1970-01-01 00:00:01.000000 的秒数,将输入时间转换为对应时区的时间戳。
Review Comment:
输入带有时区属于cast到datetime部分的操作,不要混淆在这里。
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-monday.md:
##########
@@ -5,24 +5,71 @@
}
---
-## to_monday
## 描述
+
+将日期或带时间的日期向下舍入到最近的星期一。作为一种特殊情况,日期参数 1970-01-01、1970-01-02、1970-01-03 和
1970-01-04 返回日期 1970-01-01
+
+
## 语法
-`DATE to_monday(DATETIME date)`
+```sql
+to_monday(`<date_or_time_expr>`)
+```
-将日期或带时间的日期向下舍入到最近的星期一。作为一种特殊情况,日期参数 1970-01-01、1970-01-02、1970-01-03 和
1970-01-04 返回日期 1970-01-01
+## 参数
+
+| 参数 | 描述 |
+|----------------------------|-----------------------------|
+| `<datetime_or_date>` | 输入的日期时间值,支持输入 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)
|
+
+## 返回值
+
+返回类型为 DATE(格式 YYYY-MM-DD),表示输入日期所在周的星期一。
Review Comment:
不需要描述格式
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md:
##########
@@ -1,34 +1,62 @@
---
{
- "title": "TO_DATE",
- "language": "zh-CN"
+ "title": "TO_DATE",
+ "language": "zh-CN"
}
---
-## 描述
-日期转换函数,用于将日期时间(DATETIME)转换为日期类型(DATE),即去掉时间部分,仅保留日期(YYYY-MM-DD)
+## 描述
+该函数等价于 cast(string to date)
+TO_DATE 函数用于将日期时间值转换为 DATE 类型(仅包含年月日,格式为
YYYY-MM-DD)。该函数会自动忽略输入中的时间部分(时、分、秒、微秒),仅提取日期部分进行转换。
## 语法
```sql
-TO_DATE(<datetime_value>)
+TO_DATE(`<datetime_value>`)
```
-## 必选参数
+## 参数
| 参数 | 描述 |
|------------------|--------------------|
-| `datetime_value` | DATETIME 类型日期时间 |
+| `<datetime_value>` | DATETIME 类型日期时间,支持 DATETIME ,datetime 格式请查看 [datetime
的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion)
|
+## 返回值
+将输入日期时间提取其中的日期返回,类型为 DATE。
+- 若输入 NULL ,返回 NULL
## 举例
-将 `2020-02-02 00:00:00` 转换为 `2020-02-02`
```sql
+
+--提取 datetime 中的 日期部分
select to_date("2020-02-02 00:00:00");
-```
-```text
+
+--------------------------------+
| to_date('2020-02-02 00:00:00') |
+--------------------------------+
| 2020-02-02 |
+--------------------------------+
+
+---输入 date ,返回本身
+select to_date("2020-02-02");
++-----------------------+
+| to_date("2020-02-02") |
++-----------------------+
+| 2020-02-02 |
++-----------------------+
+
+---无效日期时间,返回 NULL
+SELECT TO_DATE('2023-02-30 23:23:56') AS result;
Review Comment:
不需要这种case
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/unix-timestamp.md:
##########
@@ -34,22 +53,30 @@ UNIX_TIMESTAMP([DATETIME date[, STRING fmt]])
## 返回值
根据输入返回两种类型
-1.若是输入的 `date` (只有 datetime 类型才可以有 scale 不为零) scale 不为 0 或者带有 `format` 参数
+1.若是输入的 date 为 datetime 类型且 scale 不为零或者带有 format 参数
返回一个时间戳,类型为 Decimal,最高六位小数精度
-2.若是输入的 `date` scale 为 0 并且不带有 `format` 参数
+2.若是输入的 date 或 scale 为 0 并且不带有 format 参数
返回一个时间戳,类型为 INT
-支持的输入范围为 '1970-01-01 00:00:00.000000 UTC' 至 '9999-12-31 23:59:59.999999
UTC'。早于最小值的时间返回 0。
+基于 UTC 时区的1970-01-01 00:00:01.000000 的秒数,将输入时间转换为当前机器所在时区所对应的时间戳.
Review Comment:
这个描述有些迷惑啊,前后半句似乎没什么关联。没有描述基于……怎么转换。
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/unix-timestamp.md:
##########
@@ -34,22 +53,30 @@ UNIX_TIMESTAMP([DATETIME date[, STRING fmt]])
## 返回值
根据输入返回两种类型
-1.若是输入的 `date` (只有 datetime 类型才可以有 scale 不为零) scale 不为 0 或者带有 `format` 参数
+1.若是输入的 date 为 datetime 类型且 scale 不为零或者带有 format 参数
返回一个时间戳,类型为 Decimal,最高六位小数精度
-2.若是输入的 `date` scale 为 0 并且不带有 `format` 参数
+2.若是输入的 date 或 scale 为 0 并且不带有 format 参数
返回一个时间戳,类型为 INT
-支持的输入范围为 '1970-01-01 00:00:00.000000 UTC' 至 '9999-12-31 23:59:59.999999
UTC'。早于最小值的时间返回 0。
+基于 UTC 时区的1970-01-01 00:00:01.000000 的秒数,将输入时间转换为当前机器所在时区所对应的时间戳.
+若输入带有时区,则返回基于 UTC 时区的1970-01-01 00:00:01.000000 的秒数,将输入时间转换为对应时区的时间戳。
+对于在 1970-01-01 00:00:01.000000 UTC 之前的时间,该函数将返回 0。
+也可以通过变量`time_zone` 来控制机器所在时区。
任意参数为 null 则返回 null
## 举例
```sql
-
----以下都是在 UTC 时区返回的结果
-set time_zone= 'UTC';
+---当前机器所在的时区为东八区 (set time_zone = "+08:00")
+mysql> select unix_timestamp('1970-01-01 +08:00');
Review Comment:
需要一个输入1970-01-01的例子。
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-monday.md:
##########
@@ -5,24 +5,71 @@
}
---
-## to_monday
## 描述
+
+将日期或带时间的日期向下舍入到最近的星期一。作为一种特殊情况,日期参数 1970-01-01、1970-01-02、1970-01-03 和
1970-01-04 返回日期 1970-01-01
+
+
## 语法
-`DATE to_monday(DATETIME date)`
+```sql
+to_monday(`<date_or_time_expr>`)
+```
-将日期或带时间的日期向下舍入到最近的星期一。作为一种特殊情况,日期参数 1970-01-01、1970-01-02、1970-01-03 和
1970-01-04 返回日期 1970-01-01
+## 参数
+
+| 参数 | 描述 |
+|----------------------------|-----------------------------|
+| `<datetime_or_date>` | 输入的日期时间值,支持输入 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)
|
+
+## 返回值
+
+返回类型为 DATE(格式 YYYY-MM-DD),表示输入日期所在周的星期一。
+
+- 若输入为 1970-01-01、1970-01-02、1970-01-03、1970-01-04 中的任一日期,固定返回 1970-01-01;
+- 若输入为 NULL,返回 NULL;
## 举例
-```
-MySQL [(none)]> select to_monday('2022-09-10');
-+----------------------------------+
-| to_monday('2022-09-10 00:00:00') |
-+----------------------------------+
-| 2022-09-05 |
-+----------------------------------+
-```
+```sql
Review Comment:
输入datetime类型的测试
##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/unix-timestamp.md:
##########
@@ -34,22 +53,30 @@ UNIX_TIMESTAMP([DATETIME date[, STRING fmt]])
## 返回值
根据输入返回两种类型
-1.若是输入的 `date` (只有 datetime 类型才可以有 scale 不为零) scale 不为 0 或者带有 `format` 参数
+1.若是输入的 date 为 datetime 类型且 scale 不为零或者带有 format 参数
返回一个时间戳,类型为 Decimal,最高六位小数精度
-2.若是输入的 `date` scale 为 0 并且不带有 `format` 参数
+2.若是输入的 date 或 scale 为 0 并且不带有 format 参数
返回一个时间戳,类型为 INT
-支持的输入范围为 '1970-01-01 00:00:00.000000 UTC' 至 '9999-12-31 23:59:59.999999
UTC'。早于最小值的时间返回 0。
+基于 UTC 时区的1970-01-01 00:00:01.000000 的秒数,将输入时间转换为当前机器所在时区所对应的时间戳.
+若输入带有时区,则返回基于 UTC 时区的1970-01-01 00:00:01.000000 的秒数,将输入时间转换为对应时区的时间戳。
+对于在 1970-01-01 00:00:01.000000 UTC 之前的时间,该函数将返回 0。
+也可以通过变量`time_zone` 来控制机器所在时区。
任意参数为 null 则返回 null
## 举例
```sql
-
----以下都是在 UTC 时区返回的结果
-set time_zone= 'UTC';
+---当前机器所在的时区为东八区 (set time_zone = "+08:00")
+mysql> select unix_timestamp('1970-01-01 +08:00');
Review Comment:
把这个例子改成1970-01-01 00:00:00。你当前的写法Timezone不生效
--
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]