You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by zc...@apache.org on 2025/11/13 12:24:52 UTC
(doris-website) branch master updated: add date_add timeunit (#3094)
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 c0d9373351e add date_add timeunit (#3094)
c0d9373351e is described below
commit c0d9373351e7b19ceaec29e0fa99afaef99bec08
Author: csding <65...@users.noreply.github.com>
AuthorDate: Thu Nov 13 20:24:47 2025 +0800
add date_add timeunit (#3094)
## Versions
- [x] dev
- [x] 4.x
- [ ] 3.x
- [ ] 2.1
## Languages
- [x] Chinese
- [x] English
---
.../date-time-functions/date-add.md | 28 ++++++++++++++--------
.../date-time-functions/date-add.md | 28 ++++++++++++++--------
.../date-time-functions/date-add.md | 28 ++++++++++++++--------
.../date-time-functions/date-add.md | 28 ++++++++++++++--------
4 files changed, 72 insertions(+), 40 deletions(-)
diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
index 21cd1d09c0f..f702f91df5b 100644
--- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
+++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
@@ -12,14 +12,6 @@ The DATE_ADD function is used to add a specified time interval to a specified da
- Supported input date types include DATE, DATETIME (such as '2023-12-31', '2023-12-31 23:59:59').
- The time interval is specified by both a numeric value (`expr`) and a unit (`time_unit`). When `expr` is positive, it means "add", and when it is negative, it is equivalent to "subtract" the corresponding interval.
-This function behaves generally consistently with the [date_add function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_date-add) in MySQL, but the difference is that MySQL supports compound unit additions and subtractions, such as:
-
-```sql
-SELECT DATE_ADD('2100-12-31 23:59:59',INTERVAL '1:1' MINUTE_SECOND);
- -> '2101-01-01 00:01:00'
-```
-Doris does not support this type of input.
-
## Aliases
- days_add
@@ -37,7 +29,7 @@ DATE_ADD(<date_or_time_expr>, <expr> <time_unit>)
| -- | -- |
| `<date_or_time_expr>` | The date/time value to be processed. Supported types: datetime or date type, with a maximum precision of six decimal places for seconds (e.g., 2022-12-28 23:59:59.999999). For specific datetime and date formats, please refer to [datetime conversion](../../../../sql-manual/basic-element/sql-data-types/conversion/datetime-conversion) and [date conversion](../../../../sql-manual/basic-element/sql-data-types/conversion/date-conversion) |
| `<expr>` | The time interval to be added, of `INT` type |
-| `<time_unit>` | Enumeration values: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND |
+| `<time_unit>` | Enumeration values: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, DAY_SECOND, DAY_HOUR |
## Return Value
@@ -104,6 +96,22 @@ mysql> select DATE_ADD('2023-12-31 23:00:00', INTERVAL 2 HOUR);
| 2024-01-01 01:00:00 |
+--------------------------------------------------+
+-- Add DAY_SECOND
+mysql> select DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 1:2:3' DAY_SECOND);
++-------------------------------------------------------------------+
+| DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 1:2:3' DAY_SECOND) |
++-------------------------------------------------------------------+
+| 2025-10-24 11:12:13 |
++-------------------------------------------------------------------+
+
+-- Add DAY_HOUR
+mysql> select DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 2' DAY_HOUR);
++----------------------------------------------------------+
+| DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 2' DAY_HOUR) |
++----------------------------------------------------------+
+| 2025-10-24 12:10:10 |
++----------------------------------------------------------+
+
-- Illegal unit
select DATE_ADD('2023-12-31 23:00:00', INTERVAL 2 sa);
ERROR 1105 (HY000): errCode = 2, detailMessage =
@@ -123,4 +131,4 @@ ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.2)[E-218]Operation ye
mysql> select DATE_ADD('9999-01-28', INTERVAL 2 YEAR);
ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.2)[E-218]Operation years_add of 9999-01-28, 2 out of range
-```
\ No newline at end of file
+```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
index 23aab177c08..02e8ede2ffb 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
@@ -12,14 +12,6 @@ DATE_ADD 函数用于向指定的日期或时间值添加指定的时间间隔
- 支持的输入日期类型包括 DATE、DATETIME(如 '2023-12-31'、'2023-12-31 23:59:59')。
- 时间间隔由数值(`expre`)和单位(`time_unit`)共同指定,`expr` 为正数时表示“添加”,为负数时等效于“减去”对应间隔。
-该函数与 mysql 中的 [date_add 函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_date-add) 行为大致一致,但不同的是,mysql 支持联合单位的增减,如:
-
-```sql
-SELECT DATE_ADD('2100-12-31 23:59:59',INTERVAL '1:1' MINUTE_SECOND);
- -> '2101-01-01 00:01:00'
-```
-doris 不支持这种输入。
-
## 别名
- days_add
@@ -37,7 +29,7 @@ DATE_ADD(<date_or_time_expr>, <expr> <time_unit>)
| -- | -- |
| `<date_or_time_expr>` | 待处理的日期/时间值。支持类型:为 datetime 或者 date 类型,最高有六位秒数的精度(如 2022-12-28 23:59:59.999999),具体 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))|
| `<expr>` | 希望添加的时间间隔,为 `INT` 类型|
-| `<time_unit>` | 枚举值:YEAR, QUARTER, MONTH, WEEK,DAY, HOUR, MINUTE, SECOND |
+| `<time_unit>` | 枚举值:YEAR, QUARTER, MONTH, WEEK,DAY, HOUR, MINUTE, SECOND, DAY_SECOND, DAY_HOUR |
## 返回值
@@ -103,6 +95,22 @@ mysql> select DATE_ADD('2023-12-31 23:00:00', INTERVAL 2 HOUR);
| 2024-01-01 01:00:00 |
+--------------------------------------------------+
+-- 添加 DAY_SECOND
+mysql> select DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 1:2:3' DAY_SECOND);
++-------------------------------------------------------------------+
+| DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 1:2:3' DAY_SECOND) |
++-------------------------------------------------------------------+
+| 2025-10-24 11:12:13 |
++-------------------------------------------------------------------+
+
+-- 添加 DAY_HOUR
+mysql> select DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 2' DAY_HOUR);
++----------------------------------------------------------+
+| DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 2' DAY_HOUR) |
++----------------------------------------------------------+
+| 2025-10-24 12:10:10 |
++----------------------------------------------------------+
+
---非法单位
select DATE_ADD('2023-12-31 23:00:00', INTERVAL 2 sa);
ERROR 1105 (HY000): errCode = 2, detailMessage =
@@ -122,4 +130,4 @@ ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.2)[E-218]Operation ye
mysql> select DATE_ADD('9999-01-28', INTERVAL 2 YEAR);
ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.2)[E-218]Operation years_add of 9999-01-28, 2 out of range
-```
\ No newline at end of file
+```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
index 23aab177c08..02e8ede2ffb 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
@@ -12,14 +12,6 @@ DATE_ADD 函数用于向指定的日期或时间值添加指定的时间间隔
- 支持的输入日期类型包括 DATE、DATETIME(如 '2023-12-31'、'2023-12-31 23:59:59')。
- 时间间隔由数值(`expre`)和单位(`time_unit`)共同指定,`expr` 为正数时表示“添加”,为负数时等效于“减去”对应间隔。
-该函数与 mysql 中的 [date_add 函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_date-add) 行为大致一致,但不同的是,mysql 支持联合单位的增减,如:
-
-```sql
-SELECT DATE_ADD('2100-12-31 23:59:59',INTERVAL '1:1' MINUTE_SECOND);
- -> '2101-01-01 00:01:00'
-```
-doris 不支持这种输入。
-
## 别名
- days_add
@@ -37,7 +29,7 @@ DATE_ADD(<date_or_time_expr>, <expr> <time_unit>)
| -- | -- |
| `<date_or_time_expr>` | 待处理的日期/时间值。支持类型:为 datetime 或者 date 类型,最高有六位秒数的精度(如 2022-12-28 23:59:59.999999),具体 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))|
| `<expr>` | 希望添加的时间间隔,为 `INT` 类型|
-| `<time_unit>` | 枚举值:YEAR, QUARTER, MONTH, WEEK,DAY, HOUR, MINUTE, SECOND |
+| `<time_unit>` | 枚举值:YEAR, QUARTER, MONTH, WEEK,DAY, HOUR, MINUTE, SECOND, DAY_SECOND, DAY_HOUR |
## 返回值
@@ -103,6 +95,22 @@ mysql> select DATE_ADD('2023-12-31 23:00:00', INTERVAL 2 HOUR);
| 2024-01-01 01:00:00 |
+--------------------------------------------------+
+-- 添加 DAY_SECOND
+mysql> select DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 1:2:3' DAY_SECOND);
++-------------------------------------------------------------------+
+| DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 1:2:3' DAY_SECOND) |
++-------------------------------------------------------------------+
+| 2025-10-24 11:12:13 |
++-------------------------------------------------------------------+
+
+-- 添加 DAY_HOUR
+mysql> select DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 2' DAY_HOUR);
++----------------------------------------------------------+
+| DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 2' DAY_HOUR) |
++----------------------------------------------------------+
+| 2025-10-24 12:10:10 |
++----------------------------------------------------------+
+
---非法单位
select DATE_ADD('2023-12-31 23:00:00', INTERVAL 2 sa);
ERROR 1105 (HY000): errCode = 2, detailMessage =
@@ -122,4 +130,4 @@ ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.2)[E-218]Operation ye
mysql> select DATE_ADD('9999-01-28', INTERVAL 2 YEAR);
ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.2)[E-218]Operation years_add of 9999-01-28, 2 out of range
-```
\ No newline at end of file
+```
diff --git a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
index 21cd1d09c0f..f702f91df5b 100644
--- a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
+++ b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/date-add.md
@@ -12,14 +12,6 @@ The DATE_ADD function is used to add a specified time interval to a specified da
- Supported input date types include DATE, DATETIME (such as '2023-12-31', '2023-12-31 23:59:59').
- The time interval is specified by both a numeric value (`expr`) and a unit (`time_unit`). When `expr` is positive, it means "add", and when it is negative, it is equivalent to "subtract" the corresponding interval.
-This function behaves generally consistently with the [date_add function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_date-add) in MySQL, but the difference is that MySQL supports compound unit additions and subtractions, such as:
-
-```sql
-SELECT DATE_ADD('2100-12-31 23:59:59',INTERVAL '1:1' MINUTE_SECOND);
- -> '2101-01-01 00:01:00'
-```
-Doris does not support this type of input.
-
## Aliases
- days_add
@@ -37,7 +29,7 @@ DATE_ADD(<date_or_time_expr>, <expr> <time_unit>)
| -- | -- |
| `<date_or_time_expr>` | The date/time value to be processed. Supported types: datetime or date type, with a maximum precision of six decimal places for seconds (e.g., 2022-12-28 23:59:59.999999). For specific datetime and date formats, please refer to [datetime conversion](../../../../sql-manual/basic-element/sql-data-types/conversion/datetime-conversion) and [date conversion](../../../../sql-manual/basic-element/sql-data-types/conversion/date-conversion) |
| `<expr>` | The time interval to be added, of `INT` type |
-| `<time_unit>` | Enumeration values: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND |
+| `<time_unit>` | Enumeration values: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, DAY_SECOND, DAY_HOUR |
## Return Value
@@ -104,6 +96,22 @@ mysql> select DATE_ADD('2023-12-31 23:00:00', INTERVAL 2 HOUR);
| 2024-01-01 01:00:00 |
+--------------------------------------------------+
+-- Add DAY_SECOND
+mysql> select DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 1:2:3' DAY_SECOND);
++-------------------------------------------------------------------+
+| DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 1:2:3' DAY_SECOND) |
++-------------------------------------------------------------------+
+| 2025-10-24 11:12:13 |
++-------------------------------------------------------------------+
+
+-- Add DAY_HOUR
+mysql> select DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 2' DAY_HOUR);
++----------------------------------------------------------+
+| DATE_ADD('2025-10-23 10:10:10', INTERVAL '1 2' DAY_HOUR) |
++----------------------------------------------------------+
+| 2025-10-24 12:10:10 |
++----------------------------------------------------------+
+
-- Illegal unit
select DATE_ADD('2023-12-31 23:00:00', INTERVAL 2 sa);
ERROR 1105 (HY000): errCode = 2, detailMessage =
@@ -123,4 +131,4 @@ ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.2)[E-218]Operation ye
mysql> select DATE_ADD('9999-01-28', INTERVAL 2 YEAR);
ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.2)[E-218]Operation years_add of 9999-01-28, 2 out of range
-```
\ No newline at end of file
+```
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org