This is an automated email from the ASF dual-hosted git repository.

yiguolei 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 6405c18eb1a [Feature](function) Support function TO_SECONDS (#3146)
6405c18eb1a is described below

commit 6405c18eb1ac26936f7ec7f124de3d16ff71c4cc
Author: linrrarity <[email protected]>
AuthorDate: Wed Dec 10 11:01:24 2025 +0800

    [Feature](function) Support function TO_SECONDS (#3146)
    
    ## Versions
    
    - [x] dev
    - [x] 4.x
    - [ ] 3.x
    - [ ] 2.1
    
    ## Languages
    
    - [x] Chinese
    - [x] English
    
    ## Docs Checklist
    
    - [ ] Checked by AI
    - [ ] Test Cases Built
---
 .../date-time-functions/to-days.md                 | 10 ++-
 .../date-time-functions/to-seconds.md              | 73 ++++++++++++++++++++++
 .../date-time-functions/to-days.md                 | 12 +++-
 .../date-time-functions/to-seconds.md              | 70 +++++++++++++++++++++
 .../date-time-functions/to-days.md                 | 12 +++-
 .../date-time-functions/to-seconds.md              | 70 +++++++++++++++++++++
 sidebars.ts                                        |  1 +
 .../date-time-functions/to-days.md                 | 10 ++-
 .../date-time-functions/to-seconds.md              | 73 ++++++++++++++++++++++
 versioned_sidebars/version-4.x-sidebars.json       |  1 +
 10 files changed, 326 insertions(+), 6 deletions(-)

diff --git 
a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md 
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
index f91185456d6..aa2ba369250 100644
--- 
a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
+++ 
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
@@ -6,7 +6,7 @@
 ---
 
 ## Description
-A date calculation function that converts a date to a numeric value 
representing days, calculating the total number of days from December 31, year 
1 (the reference date) to the specified date.
+A date calculation function that converts a date to a numeric value 
representing days, calculating the total number of days from the base date 
(`0000-00-00`) to the specified date.
 
 This function behaves consistently with the [to_days 
function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_to-days)
 in MySQL.
 
@@ -28,6 +28,14 @@ Returns BIGINT type representing the number of days.
 ## Examples
 
 ```sql
+-- Based on the date `0000-00-00`
+select to_days('0000-01-01');
++-----------------------+
+| to_days('0000-01-01') |
++-----------------------+
+|                     1 |
++-----------------------+
+
 --input date type
 select to_days('2007-10-07');
 +---------------------------------------+
diff --git 
a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
 
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
new file mode 100644
index 00000000000..277cfcfc8a3
--- /dev/null
+++ 
b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
@@ -0,0 +1,73 @@
+---
+{
+  "title": "TO_SECONDS",
+  "language": "en"
+}
+---
+
+## Description
+
+Seconds calculation function. It converts a date to a seconds value, 
calculating the total seconds from the base date (`0000-00-00`) to the 
specified date.
+
+This function behaves consistently with the [to_seconds 
function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_to-seconds)
 in MySQL.
+
+## Syntax
+
+```sql
+TO_SECONDS(`<date_or_time_expr>`)
+```
+
+## Parameters
+
+| Parameter             | Description                                          
                                                                                
                                                                                
                                                                                
       |
+| --------------------- | 
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 |
+| `<date_or_time_expr>` | The input date/time value. Supports date/datetime 
types. For specific datetime and date formats, please refer to [datetime 
conversion](../../../basic-element/sql-data-types/conversion/datetime-conversion)
 and [date 
conversion](../../../basic-element/sql-data-types/conversion/date-conversion). |
+
+## Return Value
+
+Returns the total number of seconds from the zero date (`0000-00-00`) to the 
specified date and time, of type BIGINT. 
+
+If the input is NULL, then NULL is returned.
+
+## Examples
+
+```sql
+-- Based on the date `0000-00-00`
+select to_seconds('0000-01-01');
++--------------------------+
+| to_seconds('0000-01-01') |
++--------------------------+
+|                    86400 |
++--------------------------+
+-- Starting from 00-00, count 1 day, a total of 24 * 3600 == 86400 seconds.
+
+select to_seconds('2025-01-01'), to_seconds(20250101);
++--------------------------+----------------------+
+| to_seconds('2025-01-01') | to_seconds(20250101) |
++--------------------------+----------------------+
+|              63902908800 |          63902908800 |
++--------------------------+----------------------+
+
+SELECT
+    to_seconds('2025-01-01 11:22:33') AS datetime_type,
+    to_seconds(20250101112233) AS int_type;
++---------------+-------------+
+| datetime_type | int_type    |
++---------------+-------------+
+|   63902949753 | 63902949753 |
++---------------+-------------+
+
+select to_seconds('9999-12-31 23:59:59.999999');
++------------------------------------------+
+| to_seconds('9999-12-31 23:59:59.999999') |
++------------------------------------------+
+|                             315569519999 |
++------------------------------------------+
+
+SELECT to_seconds(NULL);
++------------------+
+| to_seconds(NULL) |
++------------------+
+|             NULL |
++------------------+
+```
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
index c3fd4c32670..8c8d9d88663 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
@@ -6,9 +6,9 @@
 ---
 
 ## 描述
-日期计算函数,它用于将日期转换为天数数值,即计算从公元 1 年 12 月 31 日(基准日期)到指定日期的总天数。
+日期计算函数,它用于将日期转换为天数数值,即计算从零日期(`0000-00-00`)到指定日期的总天数。
 
-该函数与 mysql 中的 [to_day 
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_to-days)
 行为一致。
+该函数与 mysql 中的 [to_days 
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_to-days)
 行为一致。
 
 ## 语法
 
@@ -25,6 +25,14 @@ TO_DAYS(`<date_or_time_expr>`)
 ## 举例
 
 ```sql
+-- 以`0000-00-00`为基准日期
+select to_days('0000-01-01');
++-----------------------+
+| to_days('0000-01-01') |
++-----------------------+
+|                     1 |
++-----------------------+
+
 --输入 date 类型
 select to_days('2007-10-07');
 +---------------------------------------+
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
new file mode 100644
index 00000000000..7102ca62095
--- /dev/null
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
@@ -0,0 +1,70 @@
+---
+{
+  "title": "TO_SECONDS",
+  "language": "zh-CN"
+}
+---
+
+## 描述
+秒数计算函数,它用于将日期转换为秒数值,即计算从零日期(`0000-00-00`)到指定日期时间的总秒数。
+
+该函数与 mysql 中的 [to_seconds 
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_to-seconds)
 行为一致。
+
+## 语法
+
+```sql
+TO_SECONDS(`<date_or_time_expr>`)
+```
+
+## 参数
+| 参数                         | 描述                          |
+|----------------------------|-----------------------------|
+| `<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)
 |
+
+## 返回值
+返回从零日期(`0000-00-00`)到指定日期时间的总秒数,类型为 BIGINT。
+
+若输入为 NULL 则返回 NULL。
+
+## 举例
+
+```sql
+-- 以`0000-00-00`为基准日期
+select to_seconds('0000-01-01');
++--------------------------+
+| to_seconds('0000-01-01') |
++--------------------------+
+|                    86400 |
++--------------------------+
+-- 从 00-00算 1 天,共 24 * 3600 == 86400s
+
+select to_seconds('2025-01-01'), to_seconds(20250101);
++--------------------------+----------------------+
+| to_seconds('2025-01-01') | to_seconds(20250101) |
++--------------------------+----------------------+
+|              63902908800 |          63902908800 |
++--------------------------+----------------------+
+
+SELECT
+    to_seconds('2025-01-01 11:22:33') AS datetime_type,
+    to_seconds(20250101112233) AS int_type;
++---------------+-------------+
+| datetime_type | int_type    |
++---------------+-------------+
+|   63902949753 | 63902949753 |
++---------------+-------------+
+
+select to_seconds('9999-12-31 23:59:59.999999');
++------------------------------------------+
+| to_seconds('9999-12-31 23:59:59.999999') |
++------------------------------------------+
+|                             315569519999 |
++------------------------------------------+
+
+SELECT to_seconds(NULL);
++------------------+
+| to_seconds(NULL) |
++------------------+
+|             NULL |
++------------------+
+```
\ 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/to-days.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
index c3fd4c32670..8c8d9d88663 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
@@ -6,9 +6,9 @@
 ---
 
 ## 描述
-日期计算函数,它用于将日期转换为天数数值,即计算从公元 1 年 12 月 31 日(基准日期)到指定日期的总天数。
+日期计算函数,它用于将日期转换为天数数值,即计算从零日期(`0000-00-00`)到指定日期的总天数。
 
-该函数与 mysql 中的 [to_day 
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_to-days)
 行为一致。
+该函数与 mysql 中的 [to_days 
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_to-days)
 行为一致。
 
 ## 语法
 
@@ -25,6 +25,14 @@ TO_DAYS(`<date_or_time_expr>`)
 ## 举例
 
 ```sql
+-- 以`0000-00-00`为基准日期
+select to_days('0000-01-01');
++-----------------------+
+| to_days('0000-01-01') |
++-----------------------+
+|                     1 |
++-----------------------+
+
 --输入 date 类型
 select to_days('2007-10-07');
 +---------------------------------------+
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
new file mode 100644
index 00000000000..f21642878d1
--- /dev/null
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
@@ -0,0 +1,70 @@
+---
+{
+  "title": "TO_SECONDS",
+  "language": "zh-CN"
+}
+---
+
+## 描述
+秒数计算函数,它用于将日期转换为秒数值,即计算从零日期(`0000-00-00`)到指定日期时间的总秒数。
+
+该函数与 mysql 中的 [to_seconds 
函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_to-seconds)
 行为一致。
+
+## 语法
+
+```sql
+TO_SECONDS(`<date_or_time_expr>`)
+```
+
+## 参数
+|----------------------------|-----------------------------|
+| `<date_or_time_expr>` | 输入的日期时间值,支持输入 date/datetime 类型,具体 datetime 和 date 
格式请查看 [datetime 
的转换](../../../basic-element/sql-data-types/conversion/datetime-conversion) 和 
[date 的转换](../../../basic-element/sql-data-types/conversion/date-conversion) |
+
+## 返回值
+返回从零日期(`0000-00-00`)到指定日期时间的总秒数,类型为 BIGINT。
+
+若输入为 NULL 则返回 NULL。
+
+
+## 举例
+
+```sql
+-- 以`0000-00-00`为基准日期
+select to_seconds('0000-01-01');
++--------------------------+
+| to_seconds('0000-01-01') |
++--------------------------+
+|                    86400 |
++--------------------------+
+-- 从 00-00算 1 天,共 24 * 3600 == 86400s
+
+select to_seconds('2025-01-01'), to_seconds(20250101);
++--------------------------+----------------------+
+| to_seconds('2025-01-01') | to_seconds(20250101) |
++--------------------------+----------------------+
+|              63902908800 |          63902908800 |
++--------------------------+----------------------+
+
+SELECT
+    to_seconds('2025-01-01 11:22:33') AS datetime_type,
+    to_seconds(20250101112233) AS int_type;
++---------------+-------------+
+| datetime_type | int_type    |
++---------------+-------------+
+|   63902949753 | 63902949753 |
++---------------+-------------+
+
+select to_seconds('9999-12-31 23:59:59.999999');
++------------------------------------------+
+| to_seconds('9999-12-31 23:59:59.999999') |
++------------------------------------------+
+|                             315569519999 |
++------------------------------------------+
+
+SELECT to_seconds(NULL);
++------------------+
+| to_seconds(NULL) |
++------------------+
+|             NULL |
++------------------+
+```
\ No newline at end of file
diff --git a/sidebars.ts b/sidebars.ts
index 8575bdf6935..a0d4f41a7b7 100644
--- a/sidebars.ts
+++ b/sidebars.ts
@@ -1446,6 +1446,7 @@ const sidebars: SidebarsConfig = {
                                         
'sql-manual/sql-functions/scalar-functions/date-time-functions/to-days',
                                         
'sql-manual/sql-functions/scalar-functions/date-time-functions/to-iso8601',
                                         
'sql-manual/sql-functions/scalar-functions/date-time-functions/to-monday',
+                                        
"sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds",
                                         
'sql-manual/sql-functions/scalar-functions/date-time-functions/utc-date',
                                         
'sql-manual/sql-functions/scalar-functions/date-time-functions/utc-time',
                                         
'sql-manual/sql-functions/scalar-functions/date-time-functions/utc-timestamp',
diff --git 
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
 
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
index f91185456d6..92d1c15cf5e 100644
--- 
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
+++ 
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md
@@ -6,7 +6,7 @@
 ---
 
 ## Description
-A date calculation function that converts a date to a numeric value 
representing days, calculating the total number of days from December 31, year 
1 (the reference date) to the specified date.
+A date calculation function that converts a date to a numeric value 
representing days, calculating the total number of days from the base date 
(`0000-00-00`) to the specified date
 
 This function behaves consistently with the [to_days 
function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_to-days)
 in MySQL.
 
@@ -28,6 +28,14 @@ Returns BIGINT type representing the number of days.
 ## Examples
 
 ```sql
+-- Based on the date `0000-00-00`
+select to_days('0000-01-01');
++-----------------------+
+| to_days('0000-01-01') |
++-----------------------+
+|                     1 |
++-----------------------+
+
 --input date type
 select to_days('2007-10-07');
 +---------------------------------------+
diff --git 
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
 
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
new file mode 100644
index 00000000000..277cfcfc8a3
--- /dev/null
+++ 
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds.md
@@ -0,0 +1,73 @@
+---
+{
+  "title": "TO_SECONDS",
+  "language": "en"
+}
+---
+
+## Description
+
+Seconds calculation function. It converts a date to a seconds value, 
calculating the total seconds from the base date (`0000-00-00`) to the 
specified date.
+
+This function behaves consistently with the [to_seconds 
function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_to-seconds)
 in MySQL.
+
+## Syntax
+
+```sql
+TO_SECONDS(`<date_or_time_expr>`)
+```
+
+## Parameters
+
+| Parameter             | Description                                          
                                                                                
                                                                                
                                                                                
       |
+| --------------------- | 
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 |
+| `<date_or_time_expr>` | The input date/time value. Supports date/datetime 
types. For specific datetime and date formats, please refer to [datetime 
conversion](../../../basic-element/sql-data-types/conversion/datetime-conversion)
 and [date 
conversion](../../../basic-element/sql-data-types/conversion/date-conversion). |
+
+## Return Value
+
+Returns the total number of seconds from the zero date (`0000-00-00`) to the 
specified date and time, of type BIGINT. 
+
+If the input is NULL, then NULL is returned.
+
+## Examples
+
+```sql
+-- Based on the date `0000-00-00`
+select to_seconds('0000-01-01');
++--------------------------+
+| to_seconds('0000-01-01') |
++--------------------------+
+|                    86400 |
++--------------------------+
+-- Starting from 00-00, count 1 day, a total of 24 * 3600 == 86400 seconds.
+
+select to_seconds('2025-01-01'), to_seconds(20250101);
++--------------------------+----------------------+
+| to_seconds('2025-01-01') | to_seconds(20250101) |
++--------------------------+----------------------+
+|              63902908800 |          63902908800 |
++--------------------------+----------------------+
+
+SELECT
+    to_seconds('2025-01-01 11:22:33') AS datetime_type,
+    to_seconds(20250101112233) AS int_type;
++---------------+-------------+
+| datetime_type | int_type    |
++---------------+-------------+
+|   63902949753 | 63902949753 |
++---------------+-------------+
+
+select to_seconds('9999-12-31 23:59:59.999999');
++------------------------------------------+
+| to_seconds('9999-12-31 23:59:59.999999') |
++------------------------------------------+
+|                             315569519999 |
++------------------------------------------+
+
+SELECT to_seconds(NULL);
++------------------+
+| to_seconds(NULL) |
++------------------+
+|             NULL |
++------------------+
+```
diff --git a/versioned_sidebars/version-4.x-sidebars.json 
b/versioned_sidebars/version-4.x-sidebars.json
index bdbedd67b36..2a5d7851d41 100644
--- a/versioned_sidebars/version-4.x-sidebars.json
+++ b/versioned_sidebars/version-4.x-sidebars.json
@@ -1468,6 +1468,7 @@
                                         
"sql-manual/sql-functions/scalar-functions/date-time-functions/to-days",
                                         
"sql-manual/sql-functions/scalar-functions/date-time-functions/to-iso8601",
                                         
"sql-manual/sql-functions/scalar-functions/date-time-functions/to-monday",
+                                        
"sql-manual/sql-functions/scalar-functions/date-time-functions/to-seconds",
                                         
"sql-manual/sql-functions/scalar-functions/date-time-functions/utc-date",
                                         
"sql-manual/sql-functions/scalar-functions/date-time-functions/utc-time",
                                         
"sql-manual/sql-functions/scalar-functions/date-time-functions/utc-timestamp",


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to