This is an automated email from the ASF dual-hosted git repository.
zclll pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push:
new 73bee625186 [doc](function) Support Add_time/sub_time function
documention (#2901)
73bee625186 is described below
commit 73bee6251865a1064b7126f3e67ce3b9c0df976f
Author: dwdwqfwe <[email protected]>
AuthorDate: Wed Nov 26 18:57:52 2025 +0800
[doc](function) Support Add_time/sub_time function documention (#2901)
support pr:
https://github.com/apache/doris/pull/56200
## Versions
- [ ] dev
- [ ] 3.0
- [ ] 2.1
- [ ] 2.0
## Languages
- [ ] Chinese
- [ ] English
## Docs Checklist
- [ ] Checked by AI
- [ ] Test Cases Built
---
.../date-time-functions/add-time.md | 98 ++++++++++++++++++++
.../date-time-functions/sub-time.md | 98 ++++++++++++++++++++
.../date-time-functions/add-time.md | 101 +++++++++++++++++++++
.../date-time-functions/sub-time.md | 99 ++++++++++++++++++++
.../date-time-functions/add-time.md | 101 +++++++++++++++++++++
.../date-time-functions/sub-time.md | 99 ++++++++++++++++++++
sidebars.ts | 2 +
.../date-time-functions/add-time.md | 98 ++++++++++++++++++++
.../date-time-functions/sub-time.md | 98 ++++++++++++++++++++
versioned_sidebars/version-4.x-sidebars.json | 2 +
10 files changed, 796 insertions(+)
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
new file mode 100644
index 00000000000..256ce255cb5
--- /dev/null
+++
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
@@ -0,0 +1,98 @@
+---
+{
+ "title": "ADD_TIME",
+ "language": "en"
+}
+---
+
+## Description
+
+Adds the specified time interval to a date/time or time expression. If the
second parameter is negative, it is equivalent to subtracting the interval from
the first parameter.
+
+## Syntax
+
+```sql
+ADD_TIME(`<date_or_time_expr>`, `<time>`)
+```
+
+## Parameters
+
+| Parameter | Description |
+| ---------------------| ----------- |
+| `<date_or_time_expr>`| A valid date expression. Supports input of
datetime/date/time types. If the type is date, it will be converted to the
start time of the day (00:00:00). For specific datetime/time formats, see
[datetime
conversion](../../../../../docs/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion)
and [time
conversion](../../../../../docs/sql-manual/basic-element/sql-data-types/conversion/time-conversion).
|
+| `<time>` | A valid time expression, representing the time value
to be added to `<date_or_time_expr>`. If negative, it means subtraction.
Supports input of time type. |
+
+## Return Value
+
+Returns the result of adding `<time>` to `<date_or_time_expr>`. The return
type depends on the type of the first parameter:
+- If the first parameter is of datetime type, returns datetime type.
+- If the first parameter is of time type, returns time type.
+
+Special cases:
+- If any input parameter is null, returns null.
+- If the first parameter is of time type and the result exceeds the time type
range, returns the maximum (or minimum) time value.
+- If the first parameter is of datetime type and the result exceeds the
datetime type range, an error is thrown.
+
+## Examples
+
+```sql
+-- Add time when the first parameter is datetime type
+SELECT ADD_TIME('2025-09-19 12:00:00', '01:30:00');
++---------------------------------------------+
+| ADD_TIME('2025-09-19 12:00:00', '01:30:00') |
++---------------------------------------------+
+| 2025-09-19 13:30:00 |
++---------------------------------------------+
+
+-- Add time when the first parameter is time type
+SELECT ADD_TIME(cast('12:15:20' as time), '00:10:40');
++------------------------------------------------+
+| ADD_TIME(cast('12:15:20' as time), '00:10:40') |
++------------------------------------------------+
+| 12:26:00 |
++------------------------------------------------+
+
+-- NULL parameter test
+SELECT ADD_TIME(NULL, '01:00:00');
++----------------------------+
+| ADD_TIME(NULL, '01:00:00') |
++----------------------------+
+| NULL |
++----------------------------+
+
+SELECT ADD_TIME('2025-09-19 12:00:00', NULL);
++---------------------------------------+
+| ADD_TIME('2025-09-19 12:00:00', NULL) |
++---------------------------------------+
+| NULL |
++---------------------------------------+
+
+SELECT ADD_TIME(NULL, NULL);
++----------------------+
+| ADD_TIME(NULL, NULL) |
++----------------------+
+| NULL |
++----------------------+
+
+-- Time type out-of-range test (returns max/min value)
+SELECT ADD_TIME(cast('835:30:00' as time), '21:00:00');
++-------------------------------------------------+
+| ADD_TIME(cast('835:30:00' as time), '21:00:00') |
++-------------------------------------------------+
+| 838:59:59 |
++-------------------------------------------------+
+
+SELECT ADD_TIME(cast('-832:30:00' as time), '-31:00:00');
++---------------------------------------------------+
+| ADD_TIME(cast('-832:30:00' as time), '-31:00:00') |
++---------------------------------------------------+
+| -838:59:59 |
++---------------------------------------------------+
+
+-- Datetime type out-of-range test (throws error)
+SELECT ADD_TIME('9999-12-31 23:59:59', '00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
add_time
+
+SELECT ADD_TIME('0000-01-01 00:00:00', '-00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
add_time
+```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
new file mode 100644
index 00000000000..b51bd4a0f71
--- /dev/null
+++
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
@@ -0,0 +1,98 @@
+---
+{
+ "title": "SUB_TIME",
+ "language": "en"
+}
+---
+
+## Description
+
+Subtracts the specified time interval from a date/time or time expression. If
the second parameter is negative, it is equivalent to adding the interval to
the first parameter.
+
+## Syntax
+
+```sql
+SUB_TIME(`<date_or_time_expr>`, `<time>`)
+```
+
+## Parameters
+
+| Parameter | Description |
+| ---------------------| ----------- |
+| `<date_or_time_expr>`| A valid date expression. Supports input of
datetime/date/time types. If the type is date, it will be converted to the
start time of the day (00:00:00). For specific datetime/time formats, see
[datetime
conversion](../../../../../docs/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion)
and [time
conversion](../../../../../docs/sql-manual/basic-element/sql-data-types/conversion/time-conversion).
|
+| `<time>` | A valid time expression, representing the time value
to be subtracted from `<date_or_time_expr>`. If negative, it means addition.
Supports input of time type. |
+
+## Return Value
+
+Returns the result of subtracting `<time>` from `<date_or_time_expr>`. The
return type depends on the type of the first parameter:
+- If the first parameter is of datetime type, returns datetime type.
+- If the first parameter is of time type, returns time type.
+
+Special cases:
+- If any input parameter is null, returns null.
+- If the first parameter is of time type and the result exceeds the time type
range, returns the maximum (or minimum) time value.
+- If the first parameter is of datetime type and the result exceeds the
datetime type range, an error is thrown.
+
+## Examples
+
+```sql
+-- Subtract time when the first parameter is datetime type
+SELECT SUB_TIME('2025-09-19 12:00:00', '01:30:00');
++---------------------------------------------+
+| SUB_TIME('2025-09-19 12:00:00', '01:30:00') |
++---------------------------------------------+
+| 2025-09-19 10:30:00 |
++---------------------------------------------+
+
+-- Subtract time when the first parameter is time type
+SELECT SUB_TIME(cast('12:15:20' as time), '00:10:40');
++------------------------------------------------+
+| SUB_TIME(cast('12:15:20' as time), '00:10:40') |
++------------------------------------------------+
+| 12:04:40 |
++------------------------------------------------+
+
+-- NULL parameter test
+SELECT SUB_TIME(NULL, '01:00:00');
++----------------------------+
+| SUB_TIME(NULL, '01:00:00') |
++----------------------------+
+| NULL |
++----------------------------+
+
+SELECT SUB_TIME('2025-09-19 12:00:00', NULL);
++---------------------------------------+
+| SUB_TIME('2025-09-19 12:00:00', NULL) |
++---------------------------------------+
+| NULL |
++---------------------------------------+
+
+SELECT SUB_TIME(NULL, NULL);
++----------------------+
+| SUB_TIME(NULL, NULL) |
++----------------------+
+| NULL |
++----------------------+
+
+-- Time type out-of-range test (returns max/min value)
+SELECT SUB_TIME(cast('835:30:00' as time), '-21:00:00');
++--------------------------------------------------+
+| SUB_TIME(cast('835:30:00' as time), '-21:00:00') |
++--------------------------------------------------+
+| 838:59:59 |
++--------------------------------------------------+
+
+SELECT SUB_TIME(cast('-832:30:00' as time), '31:00:00');
++---------------------------------------------------+
+| SUB_TIME(cast('-832:30:00' as time), '31:00:00') |
++---------------------------------------------------+
+| -838:59:59 |
++---------------------------------------------------+
+
+-- Datetime type out-of-range test (throws error)
+SELECT SUB_TIME('0000-01-01 00:00:00', '00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
sub_time
+
+SELECT SUB_TIME('9999-12-31 23:59:59', '-00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
sub_time
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
new file mode 100644
index 00000000000..d9ed1e2fd4d
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
@@ -0,0 +1,101 @@
+---
+{
+ "title": "ADD_TIME",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+将给定的时间间隔添加到日期时间/时间表达式上。若第二个参数为负数,则等价于从第一个参数中减去该时间间隔。
+
+
+## 语法
+
+```sql
+ADD_TIME(`<date_or_time_expr>`, `<time>`)
+```
+
+## 参数
+
+| 参数 | 说明 |
+| -- | -- |
+| `<date_or_time_expr>` | 参数是合法的日期表达式,支持输入 datetime/date/time 类型,date
类型会转换为对应日期的一天起始时间 00:00:00 ,具体 datetime//time 格式请查看 [datetime
的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion)
和
[time的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/time-conversion)
|
+| `<time>` | 参数为合法的时间表达式,表示增加到`<date_or_time_expr>`
上面的时间值,若为负数,则表示减少,支持输入 time 类型 |
+
+## 返回值
+
+返回 `<date_or_time_expr>` 添加 `<time>` 时间值之后的结果,根据第一个参数类型返回不同的类型
+- 若第一个参数为 datetime 类型,则返回 datetime 类型
+- 若第一个参数为 time 类型,则返回 time 类型
+
+特殊情况:
+- 若输入参数包含 null ,返回 null
+- 若第一个参数类型为 time 类型,且计算结果超出 time 类型范围,则返回 time 类型最大(最小值)
+- 若第一个参数类型为 datetime 类型,且计算结果超出 datetime 类型,则跑出错误
+
+
+## 举例
+
+```sql
+-- 增加时间当第一个参数为 datetime 类型
+SELECT ADD_TIME('2025-09-19 12:00:00', '01:30:00');
++---------------------------------------------+
+| ADD_TIME('2025-09-19 12:00:00', '01:30:00') |
++---------------------------------------------+
+| 2025-09-19 13:30:00 |
++---------------------------------------------+
+
+-- 增加时间当第一个参数为 time 类型
+SELECT ADD_TIME(cast('12:15:20' as time), '00:10:40');
++------------------------------------------------+
+| ADD_TIME(cast('12:15:20' as time), '00:10:40') |
++------------------------------------------------+
+| 12:26:00 |
++------------------------------------------------+
+
+-- NULL 参数测试
+SELECT ADD_TIME(NULL, '01:00:00');
++----------------------------+
+| ADD_TIME(NULL, '01:00:00') |
++----------------------------+
+| NULL |
++----------------------------+
+
+SELECT ADD_TIME('2025-09-19 12:00:00', NULL);
++---------------------------------------+
+| ADD_TIME('2025-09-19 12:00:00', NULL) |
++---------------------------------------+
+| NULL |
++---------------------------------------+
+
+SELECT ADD_TIME(NULL, NULL);
++----------------------+
+| ADD_TIME(NULL, NULL) |
++----------------------+
+| NULL |
++----------------------+
+
+-- time 类型超出范围测试(返回最大/最小值)
+SELECT ADD_TIME(cast('835:30:00' as time), '21:00:00');
++-------------------------------------------------+
+| ADD_TIME(cast('835:30:00' as time), '21:00:00') |
++-------------------------------------------------+
+| 838:59:59 |
++-------------------------------------------------+
+
+
+SELECT ADD_TIME(cast('-832:30:00' as time), '-31:00:00');
++---------------------------------------------------+
+| ADD_TIME(cast('-832:30:00' as time), '-31:00:00') |
++---------------------------------------------------+
+| -838:59:59 |
++---------------------------------------------------+
+
+-- datetime 类型超出范围测试(抛出错误)
+SELECT ADD_TIME('9999-12-31 23:59:59', '00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
add_time
+
+SELECT ADD_TIME('0000-01-01 00:00:00', '-00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
add_time
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
new file mode 100644
index 00000000000..a6814ebf696
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
@@ -0,0 +1,99 @@
+---
+{
+ "title": "SUB_TIME",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+从给定的日期时间/时间表达式中减去指定的时间间隔。若第二个参数为负数,则等价于向第一个参数中添加该时间间隔。
+
+## 语法
+
+```sql
+SUB_TIME(`<date_or_time_expr>`, `<time>`)
+```
+
+## 参数
+
+| 参数 | 说明 |
+| -- | -- |
+| `<date_or_time_expr>` | 参数是合法的日期表达式,支持输入 datetime/date/time 类型,date
类型会转换为对应日期的一天起始时间 00:00:00 ,具体 datetime//time 格式请查看 [datetime
的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion)
和
[time的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/time-conversion)
|
+| `<time>` | 参数为合法的时间表达式,表示从`<date_or_time_expr>`
中减去的时间值,若为负数,则表示增加,支持输入 time 类型 |
+
+## 返回值
+
+返回 `<date_or_time_expr>` 减去 `<time>` 时间值之后的结果,根据第一个参数类型返回不同的类型
+- 若第一个参数为 datetime 类型,则返回 datetime 类型
+- 若第一个参数为 time 类型,则返回 time 类型
+
+特殊情况:
+- 若输入参数包含 null ,返回 null
+- 若第一个参数类型为 time 类型,且计算结果超出 time 类型范围,则返回 time 类型最大(最小值)
+- 若第一个参数类型为 datetime 类型,且计算结果超出 datetime 类型,则跑出错误
+
+## 举例
+
+```sql
+-- 减少时间当第一个参数为 datetime 类型
+SELECT SUB_TIME('2025-09-19 12:00:00', '01:30:00');
++---------------------------------------------+
+| SUB_TIME('2025-09-19 12:00:00', '01:30:00') |
++---------------------------------------------+
+| 2025-09-19 10:30:00 |
++---------------------------------------------+
+
+-- 减少时间当第一个参数为 time 类型
+SELECT SUB_TIME(cast('12:15:20' as time), '00:10:40');
++------------------------------------------------+
+| SUB_TIME(cast('12:15:20' as time), '00:10:40') |
++------------------------------------------------+
+| 12:04:40 |
++------------------------------------------------+
+
+-- NULL 参数测试
+SELECT SUB_TIME(NULL, '01:00:00');
++----------------------------+
+| SUB_TIME(NULL, '01:00:00') |
++----------------------------+
+| NULL |
++----------------------------+
+
+SELECT SUB_TIME('2025-09-19 12:00:00', NULL);
++---------------------------------------+
+| SUB_TIME('2025-09-19 12:00:00', NULL) |
++---------------------------------------+
+| NULL |
++---------------------------------------+
+
+SELECT SUB_TIME(NULL, NULL);
++----------------------+
+| SUB_TIME(NULL, NULL) |
++----------------------+
+| NULL |
++----------------------+
+
+-- time 类型超出范围测试(返回最大/最小值)
+SELECT SUB_TIME(cast('835:30:00' as time), '-21:00:00');
++--------------------------------------------------+
+| SUB_TIME(cast('835:30:00' as time), '-21:00:00') |
++--------------------------------------------------+
+| 838:59:59 |
++--------------------------------------------------+
+
+
+SELECT SUB_TIME(cast('-832:30:00' as time), '31:00:00');
++---------------------------------------------------+
+| SUB_TIME(cast('-832:30:00' as time), '31:00:00') |
++---------------------------------------------------+
+| -838:59:59 |
++---------------------------------------------------+
+
+-- datetime 类型超出范围测试(抛出错误)
+SELECT SUB_TIME('0000-01-01 00:00:00', '00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
sub_time
+
+SELECT SUB_TIME('9999-12-31 23:59:59', '-00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
sub_time
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
new file mode 100644
index 00000000000..d9ed1e2fd4d
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
@@ -0,0 +1,101 @@
+---
+{
+ "title": "ADD_TIME",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+将给定的时间间隔添加到日期时间/时间表达式上。若第二个参数为负数,则等价于从第一个参数中减去该时间间隔。
+
+
+## 语法
+
+```sql
+ADD_TIME(`<date_or_time_expr>`, `<time>`)
+```
+
+## 参数
+
+| 参数 | 说明 |
+| -- | -- |
+| `<date_or_time_expr>` | 参数是合法的日期表达式,支持输入 datetime/date/time 类型,date
类型会转换为对应日期的一天起始时间 00:00:00 ,具体 datetime//time 格式请查看 [datetime
的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion)
和
[time的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/time-conversion)
|
+| `<time>` | 参数为合法的时间表达式,表示增加到`<date_or_time_expr>`
上面的时间值,若为负数,则表示减少,支持输入 time 类型 |
+
+## 返回值
+
+返回 `<date_or_time_expr>` 添加 `<time>` 时间值之后的结果,根据第一个参数类型返回不同的类型
+- 若第一个参数为 datetime 类型,则返回 datetime 类型
+- 若第一个参数为 time 类型,则返回 time 类型
+
+特殊情况:
+- 若输入参数包含 null ,返回 null
+- 若第一个参数类型为 time 类型,且计算结果超出 time 类型范围,则返回 time 类型最大(最小值)
+- 若第一个参数类型为 datetime 类型,且计算结果超出 datetime 类型,则跑出错误
+
+
+## 举例
+
+```sql
+-- 增加时间当第一个参数为 datetime 类型
+SELECT ADD_TIME('2025-09-19 12:00:00', '01:30:00');
++---------------------------------------------+
+| ADD_TIME('2025-09-19 12:00:00', '01:30:00') |
++---------------------------------------------+
+| 2025-09-19 13:30:00 |
++---------------------------------------------+
+
+-- 增加时间当第一个参数为 time 类型
+SELECT ADD_TIME(cast('12:15:20' as time), '00:10:40');
++------------------------------------------------+
+| ADD_TIME(cast('12:15:20' as time), '00:10:40') |
++------------------------------------------------+
+| 12:26:00 |
++------------------------------------------------+
+
+-- NULL 参数测试
+SELECT ADD_TIME(NULL, '01:00:00');
++----------------------------+
+| ADD_TIME(NULL, '01:00:00') |
++----------------------------+
+| NULL |
++----------------------------+
+
+SELECT ADD_TIME('2025-09-19 12:00:00', NULL);
++---------------------------------------+
+| ADD_TIME('2025-09-19 12:00:00', NULL) |
++---------------------------------------+
+| NULL |
++---------------------------------------+
+
+SELECT ADD_TIME(NULL, NULL);
++----------------------+
+| ADD_TIME(NULL, NULL) |
++----------------------+
+| NULL |
++----------------------+
+
+-- time 类型超出范围测试(返回最大/最小值)
+SELECT ADD_TIME(cast('835:30:00' as time), '21:00:00');
++-------------------------------------------------+
+| ADD_TIME(cast('835:30:00' as time), '21:00:00') |
++-------------------------------------------------+
+| 838:59:59 |
++-------------------------------------------------+
+
+
+SELECT ADD_TIME(cast('-832:30:00' as time), '-31:00:00');
++---------------------------------------------------+
+| ADD_TIME(cast('-832:30:00' as time), '-31:00:00') |
++---------------------------------------------------+
+| -838:59:59 |
++---------------------------------------------------+
+
+-- datetime 类型超出范围测试(抛出错误)
+SELECT ADD_TIME('9999-12-31 23:59:59', '00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
add_time
+
+SELECT ADD_TIME('0000-01-01 00:00:00', '-00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
add_time
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
new file mode 100644
index 00000000000..a6814ebf696
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
@@ -0,0 +1,99 @@
+---
+{
+ "title": "SUB_TIME",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+从给定的日期时间/时间表达式中减去指定的时间间隔。若第二个参数为负数,则等价于向第一个参数中添加该时间间隔。
+
+## 语法
+
+```sql
+SUB_TIME(`<date_or_time_expr>`, `<time>`)
+```
+
+## 参数
+
+| 参数 | 说明 |
+| -- | -- |
+| `<date_or_time_expr>` | 参数是合法的日期表达式,支持输入 datetime/date/time 类型,date
类型会转换为对应日期的一天起始时间 00:00:00 ,具体 datetime//time 格式请查看 [datetime
的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion)
和
[time的转换](../../../../../current/sql-manual/basic-element/sql-data-types/conversion/time-conversion)
|
+| `<time>` | 参数为合法的时间表达式,表示从`<date_or_time_expr>`
中减去的时间值,若为负数,则表示增加,支持输入 time 类型 |
+
+## 返回值
+
+返回 `<date_or_time_expr>` 减去 `<time>` 时间值之后的结果,根据第一个参数类型返回不同的类型
+- 若第一个参数为 datetime 类型,则返回 datetime 类型
+- 若第一个参数为 time 类型,则返回 time 类型
+
+特殊情况:
+- 若输入参数包含 null ,返回 null
+- 若第一个参数类型为 time 类型,且计算结果超出 time 类型范围,则返回 time 类型最大(最小值)
+- 若第一个参数类型为 datetime 类型,且计算结果超出 datetime 类型,则跑出错误
+
+## 举例
+
+```sql
+-- 减少时间当第一个参数为 datetime 类型
+SELECT SUB_TIME('2025-09-19 12:00:00', '01:30:00');
++---------------------------------------------+
+| SUB_TIME('2025-09-19 12:00:00', '01:30:00') |
++---------------------------------------------+
+| 2025-09-19 10:30:00 |
++---------------------------------------------+
+
+-- 减少时间当第一个参数为 time 类型
+SELECT SUB_TIME(cast('12:15:20' as time), '00:10:40');
++------------------------------------------------+
+| SUB_TIME(cast('12:15:20' as time), '00:10:40') |
++------------------------------------------------+
+| 12:04:40 |
++------------------------------------------------+
+
+-- NULL 参数测试
+SELECT SUB_TIME(NULL, '01:00:00');
++----------------------------+
+| SUB_TIME(NULL, '01:00:00') |
++----------------------------+
+| NULL |
++----------------------------+
+
+SELECT SUB_TIME('2025-09-19 12:00:00', NULL);
++---------------------------------------+
+| SUB_TIME('2025-09-19 12:00:00', NULL) |
++---------------------------------------+
+| NULL |
++---------------------------------------+
+
+SELECT SUB_TIME(NULL, NULL);
++----------------------+
+| SUB_TIME(NULL, NULL) |
++----------------------+
+| NULL |
++----------------------+
+
+-- time 类型超出范围测试(返回最大/最小值)
+SELECT SUB_TIME(cast('835:30:00' as time), '-21:00:00');
++--------------------------------------------------+
+| SUB_TIME(cast('835:30:00' as time), '-21:00:00') |
++--------------------------------------------------+
+| 838:59:59 |
++--------------------------------------------------+
+
+
+SELECT SUB_TIME(cast('-832:30:00' as time), '31:00:00');
++---------------------------------------------------+
+| SUB_TIME(cast('-832:30:00' as time), '31:00:00') |
++---------------------------------------------------+
+| -838:59:59 |
++---------------------------------------------------+
+
+-- datetime 类型超出范围测试(抛出错误)
+SELECT SUB_TIME('0000-01-01 00:00:00', '00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
sub_time
+
+SELECT SUB_TIME('9999-12-31 23:59:59', '-00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
sub_time
+```
diff --git a/sidebars.ts b/sidebars.ts
index f072475085f..d733660ba40 100644
--- a/sidebars.ts
+++ b/sidebars.ts
@@ -1350,6 +1350,7 @@ const sidebars: SidebarsConfig = {
type: 'category',
label: 'Date Functions',
items: [
+
'sql-manual/sql-functions/scalar-functions/date-time-functions/add-time',
'sql-manual/sql-functions/scalar-functions/date-time-functions/century',
'sql-manual/sql-functions/scalar-functions/date-time-functions/convert-tz',
'sql-manual/sql-functions/scalar-functions/date-time-functions/curdate',
@@ -1421,6 +1422,7 @@ const sidebars: SidebarsConfig = {
'sql-manual/sql-functions/scalar-functions/date-time-functions/seconds-diff',
'sql-manual/sql-functions/scalar-functions/date-time-functions/seconds-sub',
'sql-manual/sql-functions/scalar-functions/date-time-functions/str-to-date',
+
"sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time",
'sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp',
'sql-manual/sql-functions/scalar-functions/date-time-functions/timestampadd',
'sql-manual/sql-functions/scalar-functions/date-time-functions/timestampdiff',
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
new file mode 100644
index 00000000000..256ce255cb5
--- /dev/null
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/add-time.md
@@ -0,0 +1,98 @@
+---
+{
+ "title": "ADD_TIME",
+ "language": "en"
+}
+---
+
+## Description
+
+Adds the specified time interval to a date/time or time expression. If the
second parameter is negative, it is equivalent to subtracting the interval from
the first parameter.
+
+## Syntax
+
+```sql
+ADD_TIME(`<date_or_time_expr>`, `<time>`)
+```
+
+## Parameters
+
+| Parameter | Description |
+| ---------------------| ----------- |
+| `<date_or_time_expr>`| A valid date expression. Supports input of
datetime/date/time types. If the type is date, it will be converted to the
start time of the day (00:00:00). For specific datetime/time formats, see
[datetime
conversion](../../../../../docs/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion)
and [time
conversion](../../../../../docs/sql-manual/basic-element/sql-data-types/conversion/time-conversion).
|
+| `<time>` | A valid time expression, representing the time value
to be added to `<date_or_time_expr>`. If negative, it means subtraction.
Supports input of time type. |
+
+## Return Value
+
+Returns the result of adding `<time>` to `<date_or_time_expr>`. The return
type depends on the type of the first parameter:
+- If the first parameter is of datetime type, returns datetime type.
+- If the first parameter is of time type, returns time type.
+
+Special cases:
+- If any input parameter is null, returns null.
+- If the first parameter is of time type and the result exceeds the time type
range, returns the maximum (or minimum) time value.
+- If the first parameter is of datetime type and the result exceeds the
datetime type range, an error is thrown.
+
+## Examples
+
+```sql
+-- Add time when the first parameter is datetime type
+SELECT ADD_TIME('2025-09-19 12:00:00', '01:30:00');
++---------------------------------------------+
+| ADD_TIME('2025-09-19 12:00:00', '01:30:00') |
++---------------------------------------------+
+| 2025-09-19 13:30:00 |
++---------------------------------------------+
+
+-- Add time when the first parameter is time type
+SELECT ADD_TIME(cast('12:15:20' as time), '00:10:40');
++------------------------------------------------+
+| ADD_TIME(cast('12:15:20' as time), '00:10:40') |
++------------------------------------------------+
+| 12:26:00 |
++------------------------------------------------+
+
+-- NULL parameter test
+SELECT ADD_TIME(NULL, '01:00:00');
++----------------------------+
+| ADD_TIME(NULL, '01:00:00') |
++----------------------------+
+| NULL |
++----------------------------+
+
+SELECT ADD_TIME('2025-09-19 12:00:00', NULL);
++---------------------------------------+
+| ADD_TIME('2025-09-19 12:00:00', NULL) |
++---------------------------------------+
+| NULL |
++---------------------------------------+
+
+SELECT ADD_TIME(NULL, NULL);
++----------------------+
+| ADD_TIME(NULL, NULL) |
++----------------------+
+| NULL |
++----------------------+
+
+-- Time type out-of-range test (returns max/min value)
+SELECT ADD_TIME(cast('835:30:00' as time), '21:00:00');
++-------------------------------------------------+
+| ADD_TIME(cast('835:30:00' as time), '21:00:00') |
++-------------------------------------------------+
+| 838:59:59 |
++-------------------------------------------------+
+
+SELECT ADD_TIME(cast('-832:30:00' as time), '-31:00:00');
++---------------------------------------------------+
+| ADD_TIME(cast('-832:30:00' as time), '-31:00:00') |
++---------------------------------------------------+
+| -838:59:59 |
++---------------------------------------------------+
+
+-- Datetime type out-of-range test (throws error)
+SELECT ADD_TIME('9999-12-31 23:59:59', '00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
add_time
+
+SELECT ADD_TIME('0000-01-01 00:00:00', '-00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
add_time
+```
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
new file mode 100644
index 00000000000..b51bd4a0f71
--- /dev/null
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time.md
@@ -0,0 +1,98 @@
+---
+{
+ "title": "SUB_TIME",
+ "language": "en"
+}
+---
+
+## Description
+
+Subtracts the specified time interval from a date/time or time expression. If
the second parameter is negative, it is equivalent to adding the interval to
the first parameter.
+
+## Syntax
+
+```sql
+SUB_TIME(`<date_or_time_expr>`, `<time>`)
+```
+
+## Parameters
+
+| Parameter | Description |
+| ---------------------| ----------- |
+| `<date_or_time_expr>`| A valid date expression. Supports input of
datetime/date/time types. If the type is date, it will be converted to the
start time of the day (00:00:00). For specific datetime/time formats, see
[datetime
conversion](../../../../../docs/sql-manual/basic-element/sql-data-types/conversion/datetime-conversion)
and [time
conversion](../../../../../docs/sql-manual/basic-element/sql-data-types/conversion/time-conversion).
|
+| `<time>` | A valid time expression, representing the time value
to be subtracted from `<date_or_time_expr>`. If negative, it means addition.
Supports input of time type. |
+
+## Return Value
+
+Returns the result of subtracting `<time>` from `<date_or_time_expr>`. The
return type depends on the type of the first parameter:
+- If the first parameter is of datetime type, returns datetime type.
+- If the first parameter is of time type, returns time type.
+
+Special cases:
+- If any input parameter is null, returns null.
+- If the first parameter is of time type and the result exceeds the time type
range, returns the maximum (or minimum) time value.
+- If the first parameter is of datetime type and the result exceeds the
datetime type range, an error is thrown.
+
+## Examples
+
+```sql
+-- Subtract time when the first parameter is datetime type
+SELECT SUB_TIME('2025-09-19 12:00:00', '01:30:00');
++---------------------------------------------+
+| SUB_TIME('2025-09-19 12:00:00', '01:30:00') |
++---------------------------------------------+
+| 2025-09-19 10:30:00 |
++---------------------------------------------+
+
+-- Subtract time when the first parameter is time type
+SELECT SUB_TIME(cast('12:15:20' as time), '00:10:40');
++------------------------------------------------+
+| SUB_TIME(cast('12:15:20' as time), '00:10:40') |
++------------------------------------------------+
+| 12:04:40 |
++------------------------------------------------+
+
+-- NULL parameter test
+SELECT SUB_TIME(NULL, '01:00:00');
++----------------------------+
+| SUB_TIME(NULL, '01:00:00') |
++----------------------------+
+| NULL |
++----------------------------+
+
+SELECT SUB_TIME('2025-09-19 12:00:00', NULL);
++---------------------------------------+
+| SUB_TIME('2025-09-19 12:00:00', NULL) |
++---------------------------------------+
+| NULL |
++---------------------------------------+
+
+SELECT SUB_TIME(NULL, NULL);
++----------------------+
+| SUB_TIME(NULL, NULL) |
++----------------------+
+| NULL |
++----------------------+
+
+-- Time type out-of-range test (returns max/min value)
+SELECT SUB_TIME(cast('835:30:00' as time), '-21:00:00');
++--------------------------------------------------+
+| SUB_TIME(cast('835:30:00' as time), '-21:00:00') |
++--------------------------------------------------+
+| 838:59:59 |
++--------------------------------------------------+
+
+SELECT SUB_TIME(cast('-832:30:00' as time), '31:00:00');
++---------------------------------------------------+
+| SUB_TIME(cast('-832:30:00' as time), '31:00:00') |
++---------------------------------------------------+
+| -838:59:59 |
++---------------------------------------------------+
+
+-- Datetime type out-of-range test (throws error)
+SELECT SUB_TIME('0000-01-01 00:00:00', '00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
sub_time
+
+SELECT SUB_TIME('9999-12-31 23:59:59', '-00:00:01');
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.3)[INVALID_ARGUMENT]datetime value is out of range in function
sub_time
+```
diff --git a/versioned_sidebars/version-4.x-sidebars.json
b/versioned_sidebars/version-4.x-sidebars.json
index 33b8bd8b124..fb1c08ba2e2 100644
--- a/versioned_sidebars/version-4.x-sidebars.json
+++ b/versioned_sidebars/version-4.x-sidebars.json
@@ -1372,6 +1372,7 @@
"type": "category",
"label": "Date Functions",
"items": [
+
"sql-manual/sql-functions/scalar-functions/date-time-functions/add-time",
"sql-manual/sql-functions/scalar-functions/date-time-functions/century",
"sql-manual/sql-functions/scalar-functions/date-time-functions/convert-tz",
"sql-manual/sql-functions/scalar-functions/date-time-functions/curdate",
@@ -1443,6 +1444,7 @@
"sql-manual/sql-functions/scalar-functions/date-time-functions/seconds-diff",
"sql-manual/sql-functions/scalar-functions/date-time-functions/seconds-sub",
"sql-manual/sql-functions/scalar-functions/date-time-functions/str-to-date",
+
"sql-manual/sql-functions/scalar-functions/date-time-functions/sub-time",
"sql-manual/sql-functions/scalar-functions/date-time-functions/timestamp",
"sql-manual/sql-functions/scalar-functions/date-time-functions/timestampadd",
"sql-manual/sql-functions/scalar-functions/date-time-functions/timestampdiff",
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]