fix: timetruncate doc issue

This commit is contained in:
dapan1121 2023-12-01 17:52:29 +08:00
parent 4d9211dcf1
commit 94cb3e3eb9
2 changed files with 1507 additions and 1505 deletions

View File

@ -626,9 +626,9 @@ TIMEDIFF(expr1, expr2 [, time_unit])
#### TIMETRUNCATE #### TIMETRUNCATE
```sql ```sql
TIMETRUNCATE(expr, time_unit [, ignore_timezone]) TIMETRUNCATE(expr, time_unit [, use_current_timezone])
ignore_timezone: { use_current_timezone: {
0 0
| 1 | 1
} }
@ -647,10 +647,11 @@ ignore_timezone: {
1b (nanoseconds), 1u (microseconds), 1a (milliseconds), 1s (seconds), 1m (minutes), 1h (hours), 1d (days), or 1w (weeks) 1b (nanoseconds), 1u (microseconds), 1a (milliseconds), 1s (seconds), 1m (minutes), 1h (hours), 1d (days), or 1w (weeks)
- The precision of the returned timestamp is same as the precision set for the current data base in use - The precision of the returned timestamp is same as the precision set for the current data base in use
- If the input data is not formatted as a timestamp, the returned value is null. - If the input data is not formatted as a timestamp, the returned value is null.
- If `1d` is used as `time_unit` to truncate the timestamp, `ignore_timezone` option can be set to indicate if the returned result is affected by client timezone or not. - When using 1d/1w as the time unit to truncate timestamp, you can specify whether to truncate based on the current time zone by setting the use_current_timezone parameter.
For example, if client timezone is set to UTC+0800, TIMETRUNCATE('2020-01-01 23:00:00', 1d, 0) will return '2020-01-01 08:00:00'. Value 0 indicates truncation using the UTC time zone, value 1 indicates truncation using the current time zone.
Otherwise, TIMETRUNCATE('2020-01-01 23:00:00', 1d, 1) will return '2020-01-01 00:00:00'. For example, if the time zone configured by the Client is UTC + 0800, TIMETRUNCATE ('2020-01-01 23:00:00', 1d, 0) returns the result of '2020-01-01 08:00:00'.
If `ignore_timezone` option is omitted, the default value is set to 1. When using TIMETRUNCATE ('2020-01-01 23:00:00', 1d, 1), the result is 2020-01-01 00:00:00 '.
When use_current_timezone is not specified, use_current_timezone defaults to 1.
#### TIMEZONE #### TIMEZONE

View File

@ -626,9 +626,9 @@ TIMEDIFF(expr1, expr2 [, time_unit])
#### TIMETRUNCATE #### TIMETRUNCATE
```sql ```sql
TIMETRUNCATE(expr, time_unit [, ignore_timezone]) TIMETRUNCATE(expr, time_unit [, use_current_timezone])
ignore_timezone: { use_current_timezone: {
0 0
| 1 | 1
} }
@ -647,10 +647,11 @@ ignore_timezone: {
1b(纳秒), 1u(微秒)1a(毫秒)1s(秒)1m(分)1h(小时)1d(天), 1w(周)。 1b(纳秒), 1u(微秒)1a(毫秒)1s(秒)1m(分)1h(小时)1d(天), 1w(周)。
- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 - 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。
- 输入包含不符合时间日期格式的字符串则返回 NULL。 - 输入包含不符合时间日期格式的字符串则返回 NULL。
- 当使用 1d 作为时间单位对时间戳进行截断时, 可通过设置 ignore_timezone 参数指定返回结果的显示是否忽略客户端时区的影响。 - 当使用 1d/1w 作为时间单位对时间戳进行截断时, 可通过设置 use_current_timezone 参数指定是否根据当前时区进行截断处理。
例如客户端所配置时区为 UTC+0800, 则 TIMETRUNCATE('2020-01-01 23:00:00', 1d, 0) 返回结果为 '2020-01-01 08:00:00'。 值 0 表示使用 UTC 时区进行截断,值 1 表示使用当前时区进行截断。
而使用 TIMETRUNCATE('2020-01-01 23:00:00', 1d, 1) 设置忽略时区时,返回结果为 '2020-01-01 00:00:00' 例如客户端所配置时区为 UTC+0800, 则 TIMETRUNCATE('2020-01-01 23:00:00', 1d, 0) 返回结果为东八区时间 '2020-01-01 08:00:00'。
ignore_timezone 如果忽略的话,则默认值为 1 。 而使用 TIMETRUNCATE('2020-01-01 23:00:00', 1d, 1) 时,返回结果为东八区时间 '2020-01-01 00:00:00'。
当不指定 use_current_timezone 时use_current_timezone 默认值为 1 。