From da56cc101a9d101716ae4def2e760c27ef267861 Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Fri, 14 Mar 2025 16:59:37 +0800 Subject: [PATCH 01/13] TO_DATE --- .../date-time-functions/to-date.md | 24 +++++++++------- .../date-time-functions/to-date.md | 24 ++++++++-------- .../date-time-functions/to-date.md | 22 ++++++++------- .../date-time-functions/to-date.md | 26 +++++++++-------- .../date-time-functions/to-date.md | 28 +++++++++++-------- .../date-time-functions/to-date.md | 28 +++++++++++-------- 6 files changed, 85 insertions(+), 67 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index b459a44bea6fc..d6f6897d6ef4f 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -24,18 +24,25 @@ specific language governing permissions and limitations under the License. --> -## to_date -### description -#### Syntax -`DATE TO_DATE(DATETIME)` +## Description +Date conversion function, used to convert a date time string or timestamp to a date type (DATE), that is, remove the time part and keep only the date (YYYY-MM-DD) -Return the DATE part of DATETIME value. +## Syntax +```sql +TO_DATE() +``` + +## Required parameter +**datetime_value**: datetime type datetime -### example +## Example +Convert `2020-02-02 00:00:00` to `2020-02-02` +```sql +select to_date("2020-02-02 00:00:00"); ``` -mysql> select to_date("2020-02-02 00:00:00"); +```text +--------------------------------+ | to_date('2020-02-02 00:00:00') | +--------------------------------+ @@ -43,6 +50,3 @@ mysql> select to_date("2020-02-02 00:00:00"); +--------------------------------+ ``` -### keywords - - TO_DATE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index ab8bbfd323c9b..ec31bee63d99c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -24,25 +24,27 @@ specific language governing permissions and limitations under the License. --> -## to_date -## 描述 -## 语法 +## 描述 +日期转换函数,用于将日期时间字符串或时间戳 转换为 日期类型(DATE),即去掉时间部分,仅保留日期(YYYY-MM-DD) -`DATE TO_DATE(DATETIME)` +## 语法 +```sql +TO_DATE() +``` -返回 DATETIME 类型中的日期部分。 +## 必选参数 +**datetime_value**:datetime 类型日期时间 ## 举例 +将 `2020-02-02 00:00:00` 转换为 `2020-02-02` +```sql +select to_date("2020-02-02 00:00:00"); ``` -mysql> select to_date("2020-02-02 00:00:00"); +```text +--------------------------------+ | to_date('2020-02-02 00:00:00') | +--------------------------------+ | 2020-02-02 | +--------------------------------+ -``` - -### keywords - - TO_DATE +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index ab8bbfd323c9b..d11b68427c480 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -24,25 +24,27 @@ specific language governing permissions and limitations under the License. --> -## to_date ## 描述 -## 语法 +日期转换函数,用于将日期时间字符串或时间戳 转换为 日期类型(DATE),即去掉时间部分,仅保留日期(YYYY-MM-DD) -`DATE TO_DATE(DATETIME)` +## 语法 +```sql +TO_DATE() +``` -返回 DATETIME 类型中的日期部分。 +## 必选参数 +**datetime_value**:datetime 类型日期时间 ## 举例 +将 `2020-02-02 00:00:00` 转换为 `2020-02-02` +```sql +select to_date("2020-02-02 00:00:00"); ``` -mysql> select to_date("2020-02-02 00:00:00"); +```text +--------------------------------+ | to_date('2020-02-02 00:00:00') | +--------------------------------+ | 2020-02-02 | +--------------------------------+ -``` - -### keywords - - TO_DATE +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index ab8bbfd323c9b..5fba17a27d9fd 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -1,7 +1,7 @@ --- { - "title": "TO_DATE", - "language": "zh-CN" + "title": "TO_DATE", + "language": "zh-CN" } --- @@ -24,25 +24,27 @@ specific language governing permissions and limitations under the License. --> -## to_date ## 描述 -## 语法 +日期转换函数,用于将日期时间字符串或时间戳 转换为 日期类型(DATE),即去掉时间部分,仅保留日期(YYYY-MM-DD) -`DATE TO_DATE(DATETIME)` +## 语法 +```sql +TO_DATE() +``` -返回 DATETIME 类型中的日期部分。 +## 必选参数 +**datetime_value**:datetime 类型日期时间 ## 举例 +将 `2020-02-02 00:00:00` 转换为 `2020-02-02` +```sql +select to_date("2020-02-02 00:00:00"); ``` -mysql> select to_date("2020-02-02 00:00:00"); +```text +--------------------------------+ | to_date('2020-02-02 00:00:00') | +--------------------------------+ | 2020-02-02 | +--------------------------------+ -``` - -### keywords - - TO_DATE +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index b459a44bea6fc..552b5ee25ce08 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -1,7 +1,7 @@ --- { - "title": "TO_DATE", - "language": "en" + "title": "TO_DATE", + "language": "en" } --- @@ -24,18 +24,25 @@ specific language governing permissions and limitations under the License. --> -## to_date -### description -#### Syntax -`DATE TO_DATE(DATETIME)` +## Description +Date conversion function, used to convert a date time string or timestamp to a date type (DATE), that is, remove the time part and keep only the date (YYYY-MM-DD) -Return the DATE part of DATETIME value. +## Syntax +```sql +TO_DATE() +``` + +## Required parameter +**datetime_value**: datetime type datetime -### example +## Example +Convert `2020-02-02 00:00:00` to `2020-02-02` +```sql +select to_date("2020-02-02 00:00:00"); ``` -mysql> select to_date("2020-02-02 00:00:00"); +```text +--------------------------------+ | to_date('2020-02-02 00:00:00') | +--------------------------------+ @@ -43,6 +50,3 @@ mysql> select to_date("2020-02-02 00:00:00"); +--------------------------------+ ``` -### keywords - - TO_DATE diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index b459a44bea6fc..552b5ee25ce08 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -1,7 +1,7 @@ --- { - "title": "TO_DATE", - "language": "en" + "title": "TO_DATE", + "language": "en" } --- @@ -24,18 +24,25 @@ specific language governing permissions and limitations under the License. --> -## to_date -### description -#### Syntax -`DATE TO_DATE(DATETIME)` +## Description +Date conversion function, used to convert a date time string or timestamp to a date type (DATE), that is, remove the time part and keep only the date (YYYY-MM-DD) -Return the DATE part of DATETIME value. +## Syntax +```sql +TO_DATE() +``` + +## Required parameter +**datetime_value**: datetime type datetime -### example +## Example +Convert `2020-02-02 00:00:00` to `2020-02-02` +```sql +select to_date("2020-02-02 00:00:00"); ``` -mysql> select to_date("2020-02-02 00:00:00"); +```text +--------------------------------+ | to_date('2020-02-02 00:00:00') | +--------------------------------+ @@ -43,6 +50,3 @@ mysql> select to_date("2020-02-02 00:00:00"); +--------------------------------+ ``` -### keywords - - TO_DATE From 01a944858a6145467644ba7b8ce26c9017a0576b Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Fri, 14 Mar 2025 17:23:46 +0800 Subject: [PATCH 02/13] TO_DAYS --- .../date-time-functions/to-days.md | 48 +++++++++++------ .../date-time-functions/to-days.md | 43 ++++++++++----- .../date-time-functions/to-days.md | 47 +++++++++++------ .../date-time-functions/to-days.md | 47 +++++++++++------ .../date-time-functions/to-days.md | 52 +++++++++++++------ .../date-time-functions/to-days.md | 52 +++++++++++++------ 6 files changed, 197 insertions(+), 92 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 db0bd9c9179d1..03c77ba0ef3f3 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 @@ -24,27 +24,45 @@ specific language governing permissions and limitations under the License. --> -## to_days -### Description -#### Syntax -`INT TO DAYS` +## Description +Date calculation function, which is used to convert a date into a day value, that is, to calculate the total number of days from December 31, 0 AD (the base date) to the specified date. +## Syntax -Days of returning date distance 0000-01-01 +```sql +TO_DAYS([ | ]) +``` + +## Optional parameters +1. **** +> datetime type datetime + +2. **** +> date type datetime -The parameter is Date or Datetime type -### example +## Example +Query how many days are there since October 7, 2007 +```sql +select to_days('2007-10-07'); ``` -mysql> select to_days('2007-10-07'); -+-----------------------+ -| to_days('2007-10-07') | -+-----------------------+ -| 733321 | -+-----------------------+ +```text ++---------------------------------------+ +| to_days(cast('2007-10-07' as DATEV2)) | ++---------------------------------------+ +| 733321 | ++---------------------------------------+ ``` -### keywords - TO_DAYS,TO,DAYS +```sql +select to_days('2007-10-07 10:03:09'); +``` +```text ++------------------------------------------------+ +| to_days(cast('2007-10-07 10:03:09' as DATEV2)) | ++------------------------------------------------+ +| 733321 | ++------------------------------------------------+ +``` 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 628ceda8b1138..b442c6678ab47 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 @@ -24,28 +24,45 @@ specific language governing permissions and limitations under the License. --> -## to_days + ## 描述 +日期计算函数,它用于将日期转换为天数数值,即计算从公元 0 年 12 月 31 日(基准日期)到指定日期的总天数。 + ## 语法 -`INT TO_DAYS(DATETIME date)` +```sql +TO_DAYS([ | ]) +``` +## 可选参数 +1. **** + > datetime 类型日期时间 -返回 date 距离 0000-01-01 的天数 +2. **** + > date 类型日期时间 -参数为 Date 或者 Datetime 类型 ## 举例 +查询2007年10月7日距今有多少天 +```sql +select to_days('2007-10-07'); ``` -mysql> select to_days('2007-10-07'); -+-----------------------+ -| to_days('2007-10-07') | -+-----------------------+ -| 733321 | -+-----------------------+ +```text ++---------------------------------------+ +| to_days(cast('2007-10-07' as DATEV2)) | ++---------------------------------------+ +| 733321 | ++---------------------------------------+ ``` -### keywords - - TO_DAYS,TO,DAYS +```sql +select to_days('2007-10-07 10:03:09'); +``` +```text ++------------------------------------------------+ +| to_days(cast('2007-10-07 10:03:09' as DATEV2)) | ++------------------------------------------------+ +| 733321 | ++------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md index 628ceda8b1138..27bbfcfe63cf6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md @@ -1,7 +1,7 @@ --- { - "title": "TO_DAYS", - "language": "zh-CN" + "title": "TO_DAYS", + "language": "zh-CN" } --- @@ -24,28 +24,45 @@ specific language governing permissions and limitations under the License. --> -## to_days + ## 描述 +日期计算函数,它用于将日期转换为天数数值,即计算从公元 0 年 12 月 31 日(基准日期)到指定日期的总天数。 + ## 语法 -`INT TO_DAYS(DATETIME date)` +```sql +TO_DAYS([ | ]) +``` +## 可选参数 +1. **** + > datetime 类型日期时间 -返回 date 距离 0000-01-01 的天数 +2. **** + > date 类型日期时间 -参数为 Date 或者 Datetime 类型 ## 举例 +查询2007年10月7日距今有多少天 +```sql +select to_days('2007-10-07'); ``` -mysql> select to_days('2007-10-07'); -+-----------------------+ -| to_days('2007-10-07') | -+-----------------------+ -| 733321 | -+-----------------------+ +```text ++---------------------------------------+ +| to_days(cast('2007-10-07' as DATEV2)) | ++---------------------------------------+ +| 733321 | ++---------------------------------------+ ``` -### keywords - - TO_DAYS,TO,DAYS +```sql +select to_days('2007-10-07 10:03:09'); +``` +```text ++------------------------------------------------+ +| to_days(cast('2007-10-07 10:03:09' as DATEV2)) | ++------------------------------------------------+ +| 733321 | ++------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md index 628ceda8b1138..27bbfcfe63cf6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md @@ -1,7 +1,7 @@ --- { - "title": "TO_DAYS", - "language": "zh-CN" + "title": "TO_DAYS", + "language": "zh-CN" } --- @@ -24,28 +24,45 @@ specific language governing permissions and limitations under the License. --> -## to_days + ## 描述 +日期计算函数,它用于将日期转换为天数数值,即计算从公元 0 年 12 月 31 日(基准日期)到指定日期的总天数。 + ## 语法 -`INT TO_DAYS(DATETIME date)` +```sql +TO_DAYS([ | ]) +``` +## 可选参数 +1. **** + > datetime 类型日期时间 -返回 date 距离 0000-01-01 的天数 +2. **** + > date 类型日期时间 -参数为 Date 或者 Datetime 类型 ## 举例 +查询2007年10月7日距今有多少天 +```sql +select to_days('2007-10-07'); ``` -mysql> select to_days('2007-10-07'); -+-----------------------+ -| to_days('2007-10-07') | -+-----------------------+ -| 733321 | -+-----------------------+ +```text ++---------------------------------------+ +| to_days(cast('2007-10-07' as DATEV2)) | ++---------------------------------------+ +| 733321 | ++---------------------------------------+ ``` -### keywords - - TO_DAYS,TO,DAYS +```sql +select to_days('2007-10-07 10:03:09'); +``` +```text ++------------------------------------------------+ +| to_days(cast('2007-10-07 10:03:09' as DATEV2)) | ++------------------------------------------------+ +| 733321 | ++------------------------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md index db0bd9c9179d1..d13250f242cc7 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md @@ -1,7 +1,7 @@ --- { - "title": "TO_DAYS", - "language": "en" + "title": "TO_DAYS", + "language": "en" } --- @@ -24,27 +24,45 @@ specific language governing permissions and limitations under the License. --> -## to_days -### Description -#### Syntax -`INT TO DAYS` +## Description +Date calculation function, which is used to convert a date into a day value, that is, to calculate the total number of days from December 31, 0 AD (the base date) to the specified date. +## Syntax -Days of returning date distance 0000-01-01 +```sql +TO_DAYS([ | ]) +``` + +## Optional parameters +1. **** +> datetime type datetime + +2. **** +> date type datetime -The parameter is Date or Datetime type -### example +## Example +Query how many days are there since October 7, 2007 +```sql +select to_days('2007-10-07'); ``` -mysql> select to_days('2007-10-07'); -+-----------------------+ -| to_days('2007-10-07') | -+-----------------------+ -| 733321 | -+-----------------------+ +```text ++---------------------------------------+ +| to_days(cast('2007-10-07' as DATEV2)) | ++---------------------------------------+ +| 733321 | ++---------------------------------------+ ``` -### keywords - TO_DAYS,TO,DAYS +```sql +select to_days('2007-10-07 10:03:09'); +``` +```text ++------------------------------------------------+ +| to_days(cast('2007-10-07 10:03:09' as DATEV2)) | ++------------------------------------------------+ +| 733321 | ++------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md index db0bd9c9179d1..d13250f242cc7 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md @@ -1,7 +1,7 @@ --- { - "title": "TO_DAYS", - "language": "en" + "title": "TO_DAYS", + "language": "en" } --- @@ -24,27 +24,45 @@ specific language governing permissions and limitations under the License. --> -## to_days -### Description -#### Syntax -`INT TO DAYS` +## Description +Date calculation function, which is used to convert a date into a day value, that is, to calculate the total number of days from December 31, 0 AD (the base date) to the specified date. +## Syntax -Days of returning date distance 0000-01-01 +```sql +TO_DAYS([ | ]) +``` + +## Optional parameters +1. **** +> datetime type datetime + +2. **** +> date type datetime -The parameter is Date or Datetime type -### example +## Example +Query how many days are there since October 7, 2007 +```sql +select to_days('2007-10-07'); ``` -mysql> select to_days('2007-10-07'); -+-----------------------+ -| to_days('2007-10-07') | -+-----------------------+ -| 733321 | -+-----------------------+ +```text ++---------------------------------------+ +| to_days(cast('2007-10-07' as DATEV2)) | ++---------------------------------------+ +| 733321 | ++---------------------------------------+ ``` -### keywords - TO_DAYS,TO,DAYS +```sql +select to_days('2007-10-07 10:03:09'); +``` +```text ++------------------------------------------------+ +| to_days(cast('2007-10-07 10:03:09' as DATEV2)) | ++------------------------------------------------+ +| 733321 | ++------------------------------------------------+ +``` From 2a237e745f6aef44fb00915a3c79f0866679e9bc Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Fri, 14 Mar 2025 18:09:53 +0800 Subject: [PATCH 03/13] year_floor --- .../date-time-functions/year-floor.md | 109 ++++++++++++----- .../date-time-functions/year-floor.md | 106 ++++++++++++---- .../date-time-functions/year-floor.md | 102 ++++++++++++---- .../date-time-functions/year-floor.md | 102 ++++++++++++---- .../date-time-functions/year-floor.md | 113 +++++++++++++----- .../date-time-functions/year-floor.md | 113 +++++++++++++----- 6 files changed, 489 insertions(+), 156 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index bb2b3ce26e1b6..d1c4bb3ba141c 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -24,39 +24,94 @@ specific language governing permissions and limitations under the License. --> -## year_floor -### description -#### Syntax -```sql -DATETIME YEAR_FLOOR(DATETIME datetime) -DATETIME YEAR_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period, DATETIME origin) -``` +## Description +It is used to round the given date down to the specified year interval starting point. It supports multiple variants, which can specify the starting time (origin) and period (period) in different ways to round. -Convert the date to the nearest rounding down time of the specified time interval period. +## Syntax -- datetime: a valid date expression. -- period: specifies how many years each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +```sql +YEAR_FLOOR([ | ]) | +YEAR_FLOOR([ | ], []) | +YEAR_FLOOR([ | ], ) | +YEAR_FLOOR([ | ], , []) +``` -### example +## Optional Parameters +| **Parameter** | **Type** | **Description** | +|-----------------------------|------------|---------------------------------------------------------| +| `` | `DATETIME` | The `DATETIME` value to be floored. | +| `` | `DATE` | The `DATE` value to be floored. | +| `` | `DATETIME` | The `DATETIME` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | +| `` | `DATE` | The `DATE` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | +| `` | `INT` | The time interval, a positive integer, specifying the number of years to floor by. | -``` -mysql> select year_floor("2023-07-13 22:28:18", 5); -+-------------------------------------------------------------+ -| year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | -+-------------------------------------------------------------+ -| 2020-01-01 00:00:00 | -+-------------------------------------------------------------+ -1 row in set (0.11 sec) -``` -### keywords +## Example +1. Rounding to the whole year + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18'); + ``` + ``` + +----------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0))) | + +----------------------------------------------------------+ + | 2023-01-01 00:00:00 | + +----------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13'); + ``` + ``` + +-------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0))) | + +-------------------------------------------------+ + | 2023-01-01 00:00:00 | + +-------------------------------------------------+ + ``` - YEAR_FLOOR, YEAR, FLOOR +2. Round based on origin + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', '2020-03-15'); + ``` + ``` + +-----------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), cast('2020-03-15' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------------+ + | 2023-03-15 00:00:00 | + +-----------------------------------------------------------------------------------------------+ + ``` -### Best Practice +3. Rounding with period as unit + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5); + ``` + ``` + +----------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5) | + +----------------------------------------------------+ + | 2020-01-01 00:00:00 | + +----------------------------------------------------+ + ``` -See also [date_floor](./date-floor) +4. Round origin and period + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', 5, '2018-06-01'); + ``` + ``` + +--------------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5, cast('2018-06-01' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------+ + | 2023-06-01 00:00:00 | + +--------------------------------------------------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5, '2016-01-01'); + ``` + ``` + +-----------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5, cast('2016-01-01' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------+ + | 2021-01-01 00:00:00 | + +-----------------------------------------------------------------------------------------+ + ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index 43abf3dd1d094..455d0b2898cc6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -24,39 +24,95 @@ specific language governing permissions and limitations under the License. --> -## year_floor ## 描述 -## 语法 +用于将给定的日期向下取整到指定的年份间隔起点。它支持多个变体,可按不同方式 指定起始时间 (origin) 和周期 (period) 进行取整。 +## 语法 ```sql -DATETIME YEAR_FLOOR(DATETIME datetime) -DATETIME YEAR_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period, DATETIME origin) +YEAR_FLOOR([ | ]) | +YEAR_FLOOR([ | ], []) | +YEAR_FLOOR([ | ], ) | +YEAR_FLOOR([ | ], , []) ``` -将日期转化为指定的时间间隔周期的最近下取整时刻。 +## 可选参数 +| **参数** | **类型** | **说明** | +|-----------------------------|------------|---------------------------------------------------| +| `` | `DATETIME` | 需要取整的 `DATETIME` 日期时间 | +| `` | `DATE` | 需要取整的 `DATE` 日期 | +| `` | `DATETIME` | 用作基准的 `DATETIME` 日期, 如果不填,默认是 0001-01-01T00:00:00 | +| `` | `DATE` | 用作基准的 `DATE` 日期, 如果不填,默认是 0001-01-01T00:00:00 | +| `` | `INT` | 取整的时间间隔,正整数,表示以多少年为周期进行取整。 | -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少天组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 ## 举例 +1. 按整年取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18'); + ``` + ``` + +----------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0))) | + +----------------------------------------------------------+ + | 2023-01-01 00:00:00 | + +----------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13'); + ``` + ``` + +-------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0))) | + +-------------------------------------------------+ + | 2023-01-01 00:00:00 | + +-------------------------------------------------+ + ``` + +2. 以 origin 为基准取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', '2020-03-15'); + ``` + ``` + +-----------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), cast('2020-03-15' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------------+ + | 2023-03-15 00:00:00 | + +-----------------------------------------------------------------------------------------------+ + ``` + +3. 以 period 为单位取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5); + ``` + ``` + +----------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5) | + +----------------------------------------------------+ + | 2020-01-01 00:00:00 | + +----------------------------------------------------+ + ``` + +4. 以 origin 和 period 取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', 5, '2018-06-01'); + ``` + ``` + +--------------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5, cast('2018-06-01' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------+ + | 2023-06-01 00:00:00 | + +--------------------------------------------------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5, '2016-01-01'); + ``` + ``` + +-----------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5, cast('2016-01-01' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------+ + | 2021-01-01 00:00:00 | + +-----------------------------------------------------------------------------------------+ + ``` -``` -mysql> select year_floor("2023-07-13 22:28:18", 5); -+-------------------------------------------------------------+ -| year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | -+-------------------------------------------------------------+ -| 2020-01-01 00:00:00 | -+-------------------------------------------------------------+ -1 row in set (0.11 sec) -``` - -### keywords - - YEAR_FLOOR, YEAR, FLOOR -### Best Practice -还可参阅 [date_floor](./date-floor) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index 43abf3dd1d094..dc3eb5c8603d7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -24,39 +24,95 @@ specific language governing permissions and limitations under the License. --> -## year_floor ## 描述 -## 语法 +用于将给定的日期向下取整到指定的年份间隔起点。它支持多个变体,可按不同方式 指定起始时间 (origin) 和周期 (period) 进行取整。 +## 语法 ```sql -DATETIME YEAR_FLOOR(DATETIME datetime) -DATETIME YEAR_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period, DATETIME origin) +YEAR_FLOOR([ | ]) | +YEAR_FLOOR([ | ], []) | +YEAR_FLOOR([ | ], ) | +YEAR_FLOOR([ | ], , []) ``` -将日期转化为指定的时间间隔周期的最近下取整时刻。 +## 可选参数 +| **参数** | **类型** | **说明** | +|-----------------------------|------------|---------------------------------------------------| +| `` | `DATETIME` | 需要取整的 `DATETIME` 日期时间 | +| `` | `DATE` | 需要取整的 `DATE` 日期 | +| `` | `DATETIME` | 用作基准的 `DATETIME` 日期, 如果不填,默认是 0001-01-01T00:00:00 | +| `` | `DATE` | 用作基准的 `DATE` 日期, 如果不填,默认是 0001-01-01T00:00:00 | +| `` | `INT` | 取整的时间间隔,正整数,表示以多少年为周期进行取整。 | -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少天组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 ## 举例 +1. 按整年取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18'); + ``` + ``` + +----------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0))) | + +----------------------------------------------------------+ + | 2023-01-01 00:00:00 | + +----------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13'); + ``` + ``` + +-------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0))) | + +-------------------------------------------------+ + | 2023-01-01 00:00:00 | + +-------------------------------------------------+ + ``` -``` -mysql> select year_floor("2023-07-13 22:28:18", 5); -+-------------------------------------------------------------+ -| year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | -+-------------------------------------------------------------+ -| 2020-01-01 00:00:00 | -+-------------------------------------------------------------+ -1 row in set (0.11 sec) -``` +2. 以 origin 为基准取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', '2020-03-15'); + ``` + ``` + +-----------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), cast('2020-03-15' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------------+ + | 2023-03-15 00:00:00 | + +-----------------------------------------------------------------------------------------------+ + ``` + +3. 以 period 为单位取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5); + ``` + ``` + +----------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5) | + +----------------------------------------------------+ + | 2020-01-01 00:00:00 | + +----------------------------------------------------+ + ``` -### keywords +4. 以 origin 和 period 取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', 5, '2018-06-01'); + ``` + ``` + +--------------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5, cast('2018-06-01' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------+ + | 2023-06-01 00:00:00 | + +--------------------------------------------------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5, '2016-01-01'); + ``` + ``` + +-----------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5, cast('2016-01-01' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------+ + | 2021-01-01 00:00:00 | + +-----------------------------------------------------------------------------------------+ + ``` - YEAR_FLOOR, YEAR, FLOOR -### Best Practice -还可参阅 [date_floor](./date-floor) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index 43abf3dd1d094..dc3eb5c8603d7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -24,39 +24,95 @@ specific language governing permissions and limitations under the License. --> -## year_floor ## 描述 -## 语法 +用于将给定的日期向下取整到指定的年份间隔起点。它支持多个变体,可按不同方式 指定起始时间 (origin) 和周期 (period) 进行取整。 +## 语法 ```sql -DATETIME YEAR_FLOOR(DATETIME datetime) -DATETIME YEAR_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period, DATETIME origin) +YEAR_FLOOR([ | ]) | +YEAR_FLOOR([ | ], []) | +YEAR_FLOOR([ | ], ) | +YEAR_FLOOR([ | ], , []) ``` -将日期转化为指定的时间间隔周期的最近下取整时刻。 +## 可选参数 +| **参数** | **类型** | **说明** | +|-----------------------------|------------|---------------------------------------------------| +| `` | `DATETIME` | 需要取整的 `DATETIME` 日期时间 | +| `` | `DATE` | 需要取整的 `DATE` 日期 | +| `` | `DATETIME` | 用作基准的 `DATETIME` 日期, 如果不填,默认是 0001-01-01T00:00:00 | +| `` | `DATE` | 用作基准的 `DATE` 日期, 如果不填,默认是 0001-01-01T00:00:00 | +| `` | `INT` | 取整的时间间隔,正整数,表示以多少年为周期进行取整。 | -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少天组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 ## 举例 +1. 按整年取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18'); + ``` + ``` + +----------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0))) | + +----------------------------------------------------------+ + | 2023-01-01 00:00:00 | + +----------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13'); + ``` + ``` + +-------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0))) | + +-------------------------------------------------+ + | 2023-01-01 00:00:00 | + +-------------------------------------------------+ + ``` -``` -mysql> select year_floor("2023-07-13 22:28:18", 5); -+-------------------------------------------------------------+ -| year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | -+-------------------------------------------------------------+ -| 2020-01-01 00:00:00 | -+-------------------------------------------------------------+ -1 row in set (0.11 sec) -``` +2. 以 origin 为基准取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', '2020-03-15'); + ``` + ``` + +-----------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), cast('2020-03-15' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------------+ + | 2023-03-15 00:00:00 | + +-----------------------------------------------------------------------------------------------+ + ``` + +3. 以 period 为单位取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5); + ``` + ``` + +----------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5) | + +----------------------------------------------------+ + | 2020-01-01 00:00:00 | + +----------------------------------------------------+ + ``` -### keywords +4. 以 origin 和 period 取整 + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', 5, '2018-06-01'); + ``` + ``` + +--------------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5, cast('2018-06-01' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------+ + | 2023-06-01 00:00:00 | + +--------------------------------------------------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5, '2016-01-01'); + ``` + ``` + +-----------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5, cast('2016-01-01' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------+ + | 2021-01-01 00:00:00 | + +-----------------------------------------------------------------------------------------+ + ``` - YEAR_FLOOR, YEAR, FLOOR -### Best Practice -还可参阅 [date_floor](./date-floor) diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index bb2b3ce26e1b6..ece9af9ff80e5 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -1,7 +1,7 @@ --- { - "title": "year_floor", - "language": "en" + "title": "year_floor", + "language": "en" } --- @@ -24,39 +24,94 @@ specific language governing permissions and limitations under the License. --> -## year_floor -### description -#### Syntax -```sql -DATETIME YEAR_FLOOR(DATETIME datetime) -DATETIME YEAR_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period, DATETIME origin) -``` +## Description +It is used to round the given date down to the specified year interval starting point. It supports multiple variants, which can specify the starting time (origin) and period (period) in different ways to round. -Convert the date to the nearest rounding down time of the specified time interval period. +## Syntax -- datetime: a valid date expression. -- period: specifies how many years each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +```sql +YEAR_FLOOR([ | ]) | +YEAR_FLOOR([ | ], []) | +YEAR_FLOOR([ | ], ) | +YEAR_FLOOR([ | ], , []) +``` -### example +## Optional Parameters +| **Parameter** | **Type** | **Description** | +|-----------------------------|------------|---------------------------------------------------------| +| `` | `DATETIME` | The `DATETIME` value to be floored. | +| `` | `DATE` | The `DATE` value to be floored. | +| `` | `DATETIME` | The `DATETIME` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | +| `` | `DATE` | The `DATE` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | +| `` | `INT` | The time interval, a positive integer, specifying the number of years to floor by. | -``` -mysql> select year_floor("2023-07-13 22:28:18", 5); -+-------------------------------------------------------------+ -| year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | -+-------------------------------------------------------------+ -| 2020-01-01 00:00:00 | -+-------------------------------------------------------------+ -1 row in set (0.11 sec) -``` -### keywords +## Example +1. Rounding to the whole year + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18'); + ``` + ``` + +----------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0))) | + +----------------------------------------------------------+ + | 2023-01-01 00:00:00 | + +----------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13'); + ``` + ``` + +-------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0))) | + +-------------------------------------------------+ + | 2023-01-01 00:00:00 | + +-------------------------------------------------+ + ``` - YEAR_FLOOR, YEAR, FLOOR +2. Round based on origin + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', '2020-03-15'); + ``` + ``` + +-----------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), cast('2020-03-15' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------------+ + | 2023-03-15 00:00:00 | + +-----------------------------------------------------------------------------------------------+ + ``` -### Best Practice +3. Rounding with period as unit + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5); + ``` + ``` + +----------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5) | + +----------------------------------------------------+ + | 2020-01-01 00:00:00 | + +----------------------------------------------------+ + ``` -See also [date_floor](./date-floor) +4. Round origin and period + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', 5, '2018-06-01'); + ``` + ``` + +--------------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5, cast('2018-06-01' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------+ + | 2023-06-01 00:00:00 | + +--------------------------------------------------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5, '2016-01-01'); + ``` + ``` + +-----------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5, cast('2016-01-01' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------+ + | 2021-01-01 00:00:00 | + +-----------------------------------------------------------------------------------------+ + ``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index bb2b3ce26e1b6..ece9af9ff80e5 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -1,7 +1,7 @@ --- { - "title": "year_floor", - "language": "en" + "title": "year_floor", + "language": "en" } --- @@ -24,39 +24,94 @@ specific language governing permissions and limitations under the License. --> -## year_floor -### description -#### Syntax -```sql -DATETIME YEAR_FLOOR(DATETIME datetime) -DATETIME YEAR_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period) -DATETIME YEAR_FLOOR(DATETIME datetime, INT period, DATETIME origin) -``` +## Description +It is used to round the given date down to the specified year interval starting point. It supports multiple variants, which can specify the starting time (origin) and period (period) in different ways to round. -Convert the date to the nearest rounding down time of the specified time interval period. +## Syntax -- datetime: a valid date expression. -- period: specifies how many years each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +```sql +YEAR_FLOOR([ | ]) | +YEAR_FLOOR([ | ], []) | +YEAR_FLOOR([ | ], ) | +YEAR_FLOOR([ | ], , []) +``` -### example +## Optional Parameters +| **Parameter** | **Type** | **Description** | +|-----------------------------|------------|---------------------------------------------------------| +| `` | `DATETIME` | The `DATETIME` value to be floored. | +| `` | `DATE` | The `DATE` value to be floored. | +| `` | `DATETIME` | The `DATETIME` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | +| `` | `DATE` | The `DATE` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | +| `` | `INT` | The time interval, a positive integer, specifying the number of years to floor by. | -``` -mysql> select year_floor("2023-07-13 22:28:18", 5); -+-------------------------------------------------------------+ -| year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | -+-------------------------------------------------------------+ -| 2020-01-01 00:00:00 | -+-------------------------------------------------------------+ -1 row in set (0.11 sec) -``` -### keywords +## Example +1. Rounding to the whole year + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18'); + ``` + ``` + +----------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0))) | + +----------------------------------------------------------+ + | 2023-01-01 00:00:00 | + +----------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13'); + ``` + ``` + +-------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0))) | + +-------------------------------------------------+ + | 2023-01-01 00:00:00 | + +-------------------------------------------------+ + ``` - YEAR_FLOOR, YEAR, FLOOR +2. Round based on origin + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', '2020-03-15'); + ``` + ``` + +-----------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), cast('2020-03-15' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------------+ + | 2023-03-15 00:00:00 | + +-----------------------------------------------------------------------------------------------+ + ``` -### Best Practice +3. Rounding with period as unit + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5); + ``` + ``` + +----------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5) | + +----------------------------------------------------+ + | 2020-01-01 00:00:00 | + +----------------------------------------------------+ + ``` -See also [date_floor](./date-floor) +4. Round origin and period + ```sql + SELECT YEAR_FLOOR('2023-07-13 22:28:18', 5, '2018-06-01'); + ``` + ``` + +--------------------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5, cast('2018-06-01' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------+ + | 2023-06-01 00:00:00 | + +--------------------------------------------------------------------------------------------------+ + ``` + ```sql + SELECT YEAR_FLOOR('2023-07-13', 5, '2016-01-01'); + ``` + ``` + +-----------------------------------------------------------------------------------------+ + | year_floor(cast('2023-07-13' as DATETIMEV2(0)), 5, cast('2016-01-01' as DATETIMEV2(0))) | + +-----------------------------------------------------------------------------------------+ + | 2021-01-01 00:00:00 | + +-----------------------------------------------------------------------------------------+ + ``` From a3ad28dd75825dc86073330520be961ce16bf4b9 Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Mon, 17 Mar 2025 11:07:51 +0800 Subject: [PATCH 04/13] WEEKS_ADD --- .../date-time-functions/weeks-add.md | 70 +++++++++++++----- .../date-time-functions/weeks-add.md | 64 ++++++++++++---- .../date-time-functions/weeks-add.md | 66 +++++++++++++---- .../date-time-functions/weeks-add.md | 66 +++++++++++++---- .../date-time-functions/weeks-add.md | 74 ++++++++++++++----- .../date-time-functions/weeks-add.md | 74 ++++++++++++++----- 6 files changed, 312 insertions(+), 102 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index bee4e5fcc080e..2f9e938445717 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -24,27 +24,63 @@ specific language governing permissions and limitations under the License. --> -## weeks_add -### description -#### Syntax +## Description +This function is used to add (or subtract) a certain number of weeks from a specified date or time value. -`DATETIME WEEKS_ADD(DATETIME date, INT weeks)` +## Syntax -ADD a specified number of weeks from a datetime or date +```sql +WEEKS_ADD([ | ], ) +``` -The parameter date can be DATETIME or DATE, and the return type is consistent with that of the parameter date. +## Required parameters +**** +> Integer, indicating the number of weeks to increase or decrease (positive number indicates increase, negative number indicates decrease) -### example +## Optional parameters +- **** + > `DATE` date type input value -``` -mysql> select weeks_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-09 02:02:02 | -+-------------------------------------+ -``` +- **** + > `DATETIME` time type input value + +## example + + +1. Add one week to the time `2020-02-02 02:02:02` + ```sql + select weeks_add("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_add('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-02-09 02:02:02 | + +-------------------------------------+ + ``` + +2. Subtract one week from the time `2020-02-02 02:02:02` + ```sql + select weeks_add("2020-02-02 02:02:02", -1); + ``` + ```text + +-------------------------------------------------------------+ + | weeks_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), -1) | + +-------------------------------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------------------------------+ + ``` + +3. Add one week to the date `2020-02-02` + ```sql + select weeks_add("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_add(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-02-09 | + +--------------------------------------------+ + ``` -### keywords - WEEKS_ADD diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index be4819050b2e0..50fe77c82c83b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -24,27 +24,61 @@ specific language governing permissions and limitations under the License. --> -## weeks_add -## 描述 +## 描述 +函数用于在指定的日期或时间值上增加(或减少)一定数量的周 + ## 语法 +```sql +WEEKS_ADD([ | ], ) +``` -`DATETIME WEEKS_ADD(DATETIME date, INT weeks)` +## 必选参数 +**** +> 整数,表示要增加或减少的周数(正数表示增加,负数表示减少) -从日期加上指定星期数 +## 可选参数 +- **** + > `DATE` 日期类型的输入值 -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型与参数 date 的类型一致。 +- **** + > `DATETIME` 时间类型的输入值 ## 举例 -``` -mysql> select weeks_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-09 02:02:02 | -+-------------------------------------+ -``` +1. 在 `2020-02-02 02:02:02` 时间上增加一周 + ```sql + select weeks_add("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_add('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-02-09 02:02:02 | + +-------------------------------------+ + ``` + +2. 在 `2020-02-02 02:02:02` 时间上减少一周 + ```sql + select weeks_add("2020-02-02 02:02:02", -1); + ``` + ```text + +-------------------------------------------------------------+ + | weeks_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), -1) | + +-------------------------------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------------------------------+ + ``` + +3. 给 `2020-02-02` 日期增加一周 + ```sql + select weeks_add("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_add(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-02-09 | + +--------------------------------------------+ + ``` -### keywords - WEEKS_ADD diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index be4819050b2e0..fe40cc765a35d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_ADD", - "language": "zh-CN" + "title": "WEEKS_ADD", + "language": "zh-CN" } --- @@ -24,27 +24,61 @@ specific language governing permissions and limitations under the License. --> -## weeks_add ## 描述 +函数用于在指定的日期或时间值上增加(或减少)一定数量的周 + ## 语法 +```sql +WEEKS_ADD([ | ], ) +``` -`DATETIME WEEKS_ADD(DATETIME date, INT weeks)` +## 必选参数 +**** +> 整数,表示要增加或减少的周数(正数表示增加,负数表示减少) -从日期加上指定星期数 +## 可选参数 +- **** + > `DATE` 日期类型的输入值 -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型与参数 date 的类型一致。 +- **** + > `DATETIME` 时间类型的输入值 ## 举例 -``` -mysql> select weeks_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-09 02:02:02 | -+-------------------------------------+ -``` +1. 在 `2020-02-02 02:02:02` 时间上增加一周 + ```sql + select weeks_add("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_add('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-02-09 02:02:02 | + +-------------------------------------+ + ``` + +2. 在 `2020-02-02 02:02:02` 时间上减少一周 + ```sql + select weeks_add("2020-02-02 02:02:02", -1); + ``` + ```text + +-------------------------------------------------------------+ + | weeks_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), -1) | + +-------------------------------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------------------------------+ + ``` + +3. 给 `2020-02-02` 日期增加一周 + ```sql + select weeks_add("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_add(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-02-09 | + +--------------------------------------------+ + ``` -### keywords - WEEKS_ADD diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index be4819050b2e0..fe40cc765a35d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_ADD", - "language": "zh-CN" + "title": "WEEKS_ADD", + "language": "zh-CN" } --- @@ -24,27 +24,61 @@ specific language governing permissions and limitations under the License. --> -## weeks_add ## 描述 +函数用于在指定的日期或时间值上增加(或减少)一定数量的周 + ## 语法 +```sql +WEEKS_ADD([ | ], ) +``` -`DATETIME WEEKS_ADD(DATETIME date, INT weeks)` +## 必选参数 +**** +> 整数,表示要增加或减少的周数(正数表示增加,负数表示减少) -从日期加上指定星期数 +## 可选参数 +- **** + > `DATE` 日期类型的输入值 -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型与参数 date 的类型一致。 +- **** + > `DATETIME` 时间类型的输入值 ## 举例 -``` -mysql> select weeks_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-09 02:02:02 | -+-------------------------------------+ -``` +1. 在 `2020-02-02 02:02:02` 时间上增加一周 + ```sql + select weeks_add("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_add('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-02-09 02:02:02 | + +-------------------------------------+ + ``` + +2. 在 `2020-02-02 02:02:02` 时间上减少一周 + ```sql + select weeks_add("2020-02-02 02:02:02", -1); + ``` + ```text + +-------------------------------------------------------------+ + | weeks_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), -1) | + +-------------------------------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------------------------------+ + ``` + +3. 给 `2020-02-02` 日期增加一周 + ```sql + select weeks_add("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_add(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-02-09 | + +--------------------------------------------+ + ``` -### keywords - WEEKS_ADD diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index bee4e5fcc080e..765f77832ec9d 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_ADD", - "language": "en" + "title": "WEEKS_ADD", + "language": "en" } --- @@ -24,27 +24,63 @@ specific language governing permissions and limitations under the License. --> -## weeks_add -### description -#### Syntax +## Description +This function is used to add (or subtract) a certain number of weeks from a specified date or time value. -`DATETIME WEEKS_ADD(DATETIME date, INT weeks)` +## Syntax -ADD a specified number of weeks from a datetime or date +```sql +WEEKS_ADD([ | ], ) +``` -The parameter date can be DATETIME or DATE, and the return type is consistent with that of the parameter date. +## Required parameters +**** +> Integer, indicating the number of weeks to increase or decrease (positive number indicates increase, negative number indicates decrease) -### example +## Optional parameters +- **** + > `DATE` date type input value -``` -mysql> select weeks_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-09 02:02:02 | -+-------------------------------------+ -``` +- **** + > `DATETIME` time type input value + +## example + + +1. Add one week to the time `2020-02-02 02:02:02` + ```sql + select weeks_add("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_add('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-02-09 02:02:02 | + +-------------------------------------+ + ``` + +2. Subtract one week from the time `2020-02-02 02:02:02` + ```sql + select weeks_add("2020-02-02 02:02:02", -1); + ``` + ```text + +-------------------------------------------------------------+ + | weeks_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), -1) | + +-------------------------------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------------------------------+ + ``` + +3. Add one week to the date `2020-02-02` + ```sql + select weeks_add("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_add(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-02-09 | + +--------------------------------------------+ + ``` -### keywords - WEEKS_ADD diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index bee4e5fcc080e..765f77832ec9d 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_ADD", - "language": "en" + "title": "WEEKS_ADD", + "language": "en" } --- @@ -24,27 +24,63 @@ specific language governing permissions and limitations under the License. --> -## weeks_add -### description -#### Syntax +## Description +This function is used to add (or subtract) a certain number of weeks from a specified date or time value. -`DATETIME WEEKS_ADD(DATETIME date, INT weeks)` +## Syntax -ADD a specified number of weeks from a datetime or date +```sql +WEEKS_ADD([ | ], ) +``` -The parameter date can be DATETIME or DATE, and the return type is consistent with that of the parameter date. +## Required parameters +**** +> Integer, indicating the number of weeks to increase or decrease (positive number indicates increase, negative number indicates decrease) -### example +## Optional parameters +- **** + > `DATE` date type input value -``` -mysql> select weeks_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-09 02:02:02 | -+-------------------------------------+ -``` +- **** + > `DATETIME` time type input value + +## example + + +1. Add one week to the time `2020-02-02 02:02:02` + ```sql + select weeks_add("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_add('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-02-09 02:02:02 | + +-------------------------------------+ + ``` + +2. Subtract one week from the time `2020-02-02 02:02:02` + ```sql + select weeks_add("2020-02-02 02:02:02", -1); + ``` + ```text + +-------------------------------------------------------------+ + | weeks_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), -1) | + +-------------------------------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------------------------------+ + ``` + +3. Add one week to the date `2020-02-02` + ```sql + select weeks_add("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_add(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-02-09 | + +--------------------------------------------+ + ``` -### keywords - WEEKS_ADD From c8211a02cd98f920975912caa3d8b78137f4886a Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Mon, 17 Mar 2025 11:25:11 +0800 Subject: [PATCH 05/13] WEEKS_DIFF --- .../date-time-functions/weeks-diff.md | 65 ++++++++++++----- .../date-time-functions/weeks-diff.md | 59 ++++++++++++---- .../date-time-functions/weeks-diff.md | 63 +++++++++++++---- .../date-time-functions/weeks-diff.md | 63 +++++++++++++---- .../date-time-functions/weeks-diff.md | 69 ++++++++++++++----- .../date-time-functions/weeks-diff.md | 69 ++++++++++++++----- 6 files changed, 293 insertions(+), 95 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index e3579a9195453..95b67292ba584 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -24,25 +24,58 @@ specific language governing permissions and limitations under the License. --> -## weeks_diff -### description -#### Syntax +## Description +Calculates the number of complete weeks (in 7-day units) between two date or time values. -`INT weeks_diff(DATETIME enddate, DATETIME startdate)` +## Syntax -The difference between the start time and the end time is weeks +```sql +WEEKS_DIFF([ | ], [ | ]) +``` -### example +## Optional parameters +| Parameter name | Data type | Description | +|----------------------|------------|----------------------| +| **`end_date`** | `DATE` | Later date | +| **`end_datetime`** | `DATETIME` | Later datetime | +| **`start_date`** | `DATE` | Earlier date | +| **`start_datetime`** | `DATETIME` | Earlier datetime | -``` -mysql> select weeks_diff('2020-12-25','2020-10-25'); -+----------------------------------------------------------+ -| weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | -+----------------------------------------------------------+ -| 8 | -+----------------------------------------------------------+ -``` -### keywords +## Example + +1. How many weeks are there between `2020-12-25` and `2020-10-25` + ```sql + select weeks_diff('2020-12-25','2020-10-25'); + ``` + ```text + +----------------------------------------------------------+ + | weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | + +----------------------------------------------------------+ + | 8 | + +----------------------------------------------------------+ + ``` + +2. How many weeks are there between `2020-12-25 10:10:02` and `2020-10-25 12:10:02` + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25 12:10:02'); + ``` + ```text + +--------------------------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25 12:10:02' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------------+ + | 8 | + +--------------------------------------------------------------------------------------------------------+ + ``` - weeks_diff +3. How many weeks are there between `2020-12-25 10:10:02` and `2020-10-25` + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25'); + ``` + ```text + +----------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25' as DATEV2)) | + +----------------------------------------------------------------------------------------+ + | 8 | + +----------------------------------------------------------------------------------------+ + ``` \ 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/weeks-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index d036f74a43c0d..d257d63a3622e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -24,25 +24,58 @@ specific language governing permissions and limitations under the License. --> -## weeks_diff ## 描述 +用于计算两个日期或时间值之间相差的完整周数(以 7 天为单位)。 + ## 语法 -`INT weeks_diff(DATETIME enddate, DATETIME startdate)` +```sql +WEEKS_DIFF([ | ], [ | ]) +``` + +## 可选参数 +| 参数名称 | 数据类型 | 描述 | +|----------------------|------------|----------------------| +| **`end_date`** | `DATE` | 较晚的日期 | +| **`end_datetime`** | `DATETIME` | 较晚的日期时间 | +| **`start_date`** | `DATE` | 较早的日期 | +| **`start_datetime`** | `DATETIME` | 较早的日期时间 | -开始时间到结束时间相差几星期 ## 举例 -``` -mysql> select weeks_diff('2020-12-25','2020-10-25'); -+----------------------------------------------------------+ -| weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | -+----------------------------------------------------------+ -| 8 | -+----------------------------------------------------------+ -``` +1. `2020-12-25` 与 `2020-10-25` 相差多少周 + ```sql + select weeks_diff('2020-12-25','2020-10-25'); + ``` + ```text + +----------------------------------------------------------+ + | weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | + +----------------------------------------------------------+ + | 8 | + +----------------------------------------------------------+ + ``` -### keywords +2. `2020-12-25 10:10:02` 与 `2020-10-25 12:10:02` 相差多少周 + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25 12:10:02'); + ``` + ```text + +--------------------------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25 12:10:02' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------------+ + | 8 | + +--------------------------------------------------------------------------------------------------------+ + ``` - weeks_diff +3. `2020-12-25 10:10:02` 与 `2020-10-25` 相差多少周 + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25'); + ``` + ```text + +----------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25' as DATEV2)) | + +----------------------------------------------------------------------------------------+ + | 8 | + +----------------------------------------------------------------------------------------+ + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index d036f74a43c0d..6155c8a3546f9 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_DIFF", - "language": "zh-CN" + "title": "WEEKS_DIFF", + "language": "zh-CN" } --- @@ -24,25 +24,58 @@ specific language governing permissions and limitations under the License. --> -## weeks_diff ## 描述 +用于计算两个日期或时间值之间相差的完整周数(以 7 天为单位)。 + ## 语法 -`INT weeks_diff(DATETIME enddate, DATETIME startdate)` +```sql +WEEKS_DIFF([ | ], [ | ]) +``` + +## 可选参数 +| 参数名称 | 数据类型 | 描述 | +|----------------------|------------|----------------------| +| **`end_date`** | `DATE` | 较晚的日期 | +| **`end_datetime`** | `DATETIME` | 较晚的日期时间 | +| **`start_date`** | `DATE` | 较早的日期 | +| **`start_datetime`** | `DATETIME` | 较早的日期时间 | -开始时间到结束时间相差几星期 ## 举例 -``` -mysql> select weeks_diff('2020-12-25','2020-10-25'); -+----------------------------------------------------------+ -| weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | -+----------------------------------------------------------+ -| 8 | -+----------------------------------------------------------+ -``` +1. `2020-12-25` 与 `2020-10-25` 相差多少周 + ```sql + select weeks_diff('2020-12-25','2020-10-25'); + ``` + ```text + +----------------------------------------------------------+ + | weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | + +----------------------------------------------------------+ + | 8 | + +----------------------------------------------------------+ + ``` -### keywords +2. `2020-12-25 10:10:02` 与 `2020-10-25 12:10:02` 相差多少周 + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25 12:10:02'); + ``` + ```text + +--------------------------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25 12:10:02' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------------+ + | 8 | + +--------------------------------------------------------------------------------------------------------+ + ``` - weeks_diff +3. `2020-12-25 10:10:02` 与 `2020-10-25` 相差多少周 + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25'); + ``` + ```text + +----------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25' as DATEV2)) | + +----------------------------------------------------------------------------------------+ + | 8 | + +----------------------------------------------------------------------------------------+ + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index d036f74a43c0d..6155c8a3546f9 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_DIFF", - "language": "zh-CN" + "title": "WEEKS_DIFF", + "language": "zh-CN" } --- @@ -24,25 +24,58 @@ specific language governing permissions and limitations under the License. --> -## weeks_diff ## 描述 +用于计算两个日期或时间值之间相差的完整周数(以 7 天为单位)。 + ## 语法 -`INT weeks_diff(DATETIME enddate, DATETIME startdate)` +```sql +WEEKS_DIFF([ | ], [ | ]) +``` + +## 可选参数 +| 参数名称 | 数据类型 | 描述 | +|----------------------|------------|----------------------| +| **`end_date`** | `DATE` | 较晚的日期 | +| **`end_datetime`** | `DATETIME` | 较晚的日期时间 | +| **`start_date`** | `DATE` | 较早的日期 | +| **`start_datetime`** | `DATETIME` | 较早的日期时间 | -开始时间到结束时间相差几星期 ## 举例 -``` -mysql> select weeks_diff('2020-12-25','2020-10-25'); -+----------------------------------------------------------+ -| weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | -+----------------------------------------------------------+ -| 8 | -+----------------------------------------------------------+ -``` +1. `2020-12-25` 与 `2020-10-25` 相差多少周 + ```sql + select weeks_diff('2020-12-25','2020-10-25'); + ``` + ```text + +----------------------------------------------------------+ + | weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | + +----------------------------------------------------------+ + | 8 | + +----------------------------------------------------------+ + ``` -### keywords +2. `2020-12-25 10:10:02` 与 `2020-10-25 12:10:02` 相差多少周 + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25 12:10:02'); + ``` + ```text + +--------------------------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25 12:10:02' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------------+ + | 8 | + +--------------------------------------------------------------------------------------------------------+ + ``` - weeks_diff +3. `2020-12-25 10:10:02` 与 `2020-10-25` 相差多少周 + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25'); + ``` + ```text + +----------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25' as DATEV2)) | + +----------------------------------------------------------------------------------------+ + | 8 | + +----------------------------------------------------------------------------------------+ + ``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index e3579a9195453..16687572b78ce 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_DIFF", - "language": "en" + "title": "WEEKS_DIFF", + "language": "en" } --- @@ -24,25 +24,58 @@ specific language governing permissions and limitations under the License. --> -## weeks_diff -### description -#### Syntax +## Description +Calculates the number of complete weeks (in 7-day units) between two date or time values. -`INT weeks_diff(DATETIME enddate, DATETIME startdate)` +## Syntax -The difference between the start time and the end time is weeks +```sql +WEEKS_DIFF([ | ], [ | ]) +``` -### example +## Optional parameters +| Parameter name | Data type | Description | +|----------------------|------------|----------------------| +| **`end_date`** | `DATE` | Later date | +| **`end_datetime`** | `DATETIME` | Later datetime | +| **`start_date`** | `DATE` | Earlier date | +| **`start_datetime`** | `DATETIME` | Earlier datetime | -``` -mysql> select weeks_diff('2020-12-25','2020-10-25'); -+----------------------------------------------------------+ -| weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | -+----------------------------------------------------------+ -| 8 | -+----------------------------------------------------------+ -``` -### keywords +## Example + +1. How many weeks are there between `2020-12-25` and `2020-10-25` + ```sql + select weeks_diff('2020-12-25','2020-10-25'); + ``` + ```text + +----------------------------------------------------------+ + | weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | + +----------------------------------------------------------+ + | 8 | + +----------------------------------------------------------+ + ``` + +2. How many weeks are there between `2020-12-25 10:10:02` and `2020-10-25 12:10:02` + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25 12:10:02'); + ``` + ```text + +--------------------------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25 12:10:02' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------------+ + | 8 | + +--------------------------------------------------------------------------------------------------------+ + ``` - weeks_diff +3. How many weeks are there between `2020-12-25 10:10:02` and `2020-10-25` + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25'); + ``` + ```text + +----------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25' as DATEV2)) | + +----------------------------------------------------------------------------------------+ + | 8 | + +----------------------------------------------------------------------------------------+ + ``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index e3579a9195453..16687572b78ce 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_DIFF", - "language": "en" + "title": "WEEKS_DIFF", + "language": "en" } --- @@ -24,25 +24,58 @@ specific language governing permissions and limitations under the License. --> -## weeks_diff -### description -#### Syntax +## Description +Calculates the number of complete weeks (in 7-day units) between two date or time values. -`INT weeks_diff(DATETIME enddate, DATETIME startdate)` +## Syntax -The difference between the start time and the end time is weeks +```sql +WEEKS_DIFF([ | ], [ | ]) +``` -### example +## Optional parameters +| Parameter name | Data type | Description | +|----------------------|------------|----------------------| +| **`end_date`** | `DATE` | Later date | +| **`end_datetime`** | `DATETIME` | Later datetime | +| **`start_date`** | `DATE` | Earlier date | +| **`start_datetime`** | `DATETIME` | Earlier datetime | -``` -mysql> select weeks_diff('2020-12-25','2020-10-25'); -+----------------------------------------------------------+ -| weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | -+----------------------------------------------------------+ -| 8 | -+----------------------------------------------------------+ -``` -### keywords +## Example + +1. How many weeks are there between `2020-12-25` and `2020-10-25` + ```sql + select weeks_diff('2020-12-25','2020-10-25'); + ``` + ```text + +----------------------------------------------------------+ + | weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | + +----------------------------------------------------------+ + | 8 | + +----------------------------------------------------------+ + ``` + +2. How many weeks are there between `2020-12-25 10:10:02` and `2020-10-25 12:10:02` + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25 12:10:02'); + ``` + ```text + +--------------------------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25 12:10:02' as DATETIMEV2(0))) | + +--------------------------------------------------------------------------------------------------------+ + | 8 | + +--------------------------------------------------------------------------------------------------------+ + ``` - weeks_diff +3. How many weeks are there between `2020-12-25 10:10:02` and `2020-10-25` + ```sql + select weeks_diff('2020-12-25 10:10:02','2020-10-25'); + ``` + ```text + +----------------------------------------------------------------------------------------+ + | weeks_diff(cast('2020-12-25 10:10:02' as DATETIMEV2(0)), cast('2020-10-25' as DATEV2)) | + +----------------------------------------------------------------------------------------+ + | 8 | + +----------------------------------------------------------------------------------------+ + ``` \ No newline at end of file From 646455ef32922bcc16824cc9a467d7b7199bf91e Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Mon, 17 Mar 2025 11:42:07 +0800 Subject: [PATCH 06/13] WEEKS_SUB --- .../date-time-functions/weeks-sub.md | 54 +++++++++++------ .../date-time-functions/weeks-sub.md | 51 +++++++++++----- .../date-time-functions/weeks-sub.md | 55 ++++++++++++------ .../date-time-functions/weeks-sub.md | 55 ++++++++++++------ .../date-time-functions/weeks-sub.md | 58 +++++++++++++------ .../date-time-functions/weeks-sub.md | 58 +++++++++++++------ 6 files changed, 227 insertions(+), 104 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 3cb574fd0c556..c09205eab59a3 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -24,27 +24,47 @@ specific language governing permissions and limitations under the License. --> -## weeks_sub -### description -#### Syntax -`DATETIME WEEKS_SUB(DATETIME date, INT weeks)` +## Description +## Syntax +```sql +WEEKS_SUB([ | ], ) +``` -Subtracts a specified number of weeks from a datetime or date +## Required parameters +**** +> Integer representing the number of weeks to be reduced (positive number means reduction, negative number means increase). -The parameter date can be DATETIME or DATE, and the return type is consistent with that of the parameter date. +## Optional parameters +- **** + > Date input value of type `DATE` -### example +- **** + > Date and time input value of type `DATETIME` -``` -mysql> select weeks_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-01-26 02:02:02 | -+-------------------------------------+ -``` -### keywords +## Example + +1. Subtract one week from the datetime `2020-02-02 02:02:02` + ```sql + select weeks_sub("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_sub('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------+ + ``` - WEEKS_SUB +2. Subtract one week from the date `2020-02-02` + ```sql + select weeks_sub("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_sub(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-01-26 | + +--------------------------------------------+ + ``` \ 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/weeks-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 948cf2ed58297..4829d1e4c4461 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -24,27 +24,48 @@ specific language governing permissions and limitations under the License. --> -## weeks_sub ## 描述 +用于在指定的日期或时间值上减少一定数量的周(即减去 weeks * 7 天)。 + ## 语法 +```sql +WEEKS_SUB([ | ], ) +``` -`DATETIME WEEKS_SUB(DATETIME date, INT weeks)` +## 必选参数 +**** +> 整数,表示要减少的周数(正数表示减少,负数表示增加)。 -从日期时间或日期减去指定星期数 +## 可选参数 +- **** + > `DATE` 类型的日期输入值 -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型与参数 date 的类型一致。 +- **** + > `DATETIME` 类型的日期时间输入值 + ## 举例 -``` -mysql> select weeks_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-01-26 02:02:02 | -+-------------------------------------+ -``` - -### keywords +1. 在 `2020-02-02 02:02:02` 日期时间上减去一周 + ```sql + select weeks_sub("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_sub('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------+ + ``` - WEEKS_SUB +2. 在 `2020-02-02` 日期上减去一周 + ```sql + select weeks_sub("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_sub(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-01-26 | + +--------------------------------------------+ + ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 948cf2ed58297..8252376ff56f1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_SUB", - "language": "zh-CN" + "title": "WEEKS_SUB", + "language": "zh-CN" } --- @@ -24,27 +24,48 @@ specific language governing permissions and limitations under the License. --> -## weeks_sub ## 描述 +用于在指定的日期或时间值上减少一定数量的周(即减去 weeks * 7 天)。 + ## 语法 +```sql +WEEKS_SUB([ | ], ) +``` -`DATETIME WEEKS_SUB(DATETIME date, INT weeks)` +## 必选参数 +**** +> 整数,表示要减少的周数(正数表示减少,负数表示增加)。 -从日期时间或日期减去指定星期数 +## 可选参数 +- **** + > `DATE` 类型的日期输入值 -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型与参数 date 的类型一致。 +- **** + > `DATETIME` 类型的日期时间输入值 -## 举例 -``` -mysql> select weeks_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-01-26 02:02:02 | -+-------------------------------------+ -``` +## 举例 -### keywords +1. 在 `2020-02-02 02:02:02` 日期时间上减去一周 + ```sql + select weeks_sub("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_sub('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------+ + ``` - WEEKS_SUB +2. 在 `2020-02-02` 日期上减去一周 + ```sql + select weeks_sub("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_sub(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-01-26 | + +--------------------------------------------+ + ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 948cf2ed58297..8252376ff56f1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_SUB", - "language": "zh-CN" + "title": "WEEKS_SUB", + "language": "zh-CN" } --- @@ -24,27 +24,48 @@ specific language governing permissions and limitations under the License. --> -## weeks_sub ## 描述 +用于在指定的日期或时间值上减少一定数量的周(即减去 weeks * 7 天)。 + ## 语法 +```sql +WEEKS_SUB([ | ], ) +``` -`DATETIME WEEKS_SUB(DATETIME date, INT weeks)` +## 必选参数 +**** +> 整数,表示要减少的周数(正数表示减少,负数表示增加)。 -从日期时间或日期减去指定星期数 +## 可选参数 +- **** + > `DATE` 类型的日期输入值 -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型与参数 date 的类型一致。 +- **** + > `DATETIME` 类型的日期时间输入值 -## 举例 -``` -mysql> select weeks_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-01-26 02:02:02 | -+-------------------------------------+ -``` +## 举例 -### keywords +1. 在 `2020-02-02 02:02:02` 日期时间上减去一周 + ```sql + select weeks_sub("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_sub('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------+ + ``` - WEEKS_SUB +2. 在 `2020-02-02` 日期上减去一周 + ```sql + select weeks_sub("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_sub(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-01-26 | + +--------------------------------------------+ + ``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 3cb574fd0c556..76270571c7d98 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_SUB", - "language": "en" + "title": "WEEKS_SUB", + "language": "en" } --- @@ -24,27 +24,47 @@ specific language governing permissions and limitations under the License. --> -## weeks_sub -### description -#### Syntax -`DATETIME WEEKS_SUB(DATETIME date, INT weeks)` +## Description +## Syntax +```sql +WEEKS_SUB([ | ], ) +``` -Subtracts a specified number of weeks from a datetime or date +## Required parameters +**** +> Integer representing the number of weeks to be reduced (positive number means reduction, negative number means increase). -The parameter date can be DATETIME or DATE, and the return type is consistent with that of the parameter date. +## Optional parameters +- **** + > Date input value of type `DATE` -### example +- **** + > Date and time input value of type `DATETIME` -``` -mysql> select weeks_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-01-26 02:02:02 | -+-------------------------------------+ -``` -### keywords +## Example + +1. Subtract one week from the datetime `2020-02-02 02:02:02` + ```sql + select weeks_sub("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_sub('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------+ + ``` - WEEKS_SUB +2. Subtract one week from the date `2020-02-02` + ```sql + select weeks_sub("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_sub(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-01-26 | + +--------------------------------------------+ + ``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 3cb574fd0c556..76270571c7d98 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_SUB", - "language": "en" + "title": "WEEKS_SUB", + "language": "en" } --- @@ -24,27 +24,47 @@ specific language governing permissions and limitations under the License. --> -## weeks_sub -### description -#### Syntax -`DATETIME WEEKS_SUB(DATETIME date, INT weeks)` +## Description +## Syntax +```sql +WEEKS_SUB([ | ], ) +``` -Subtracts a specified number of weeks from a datetime or date +## Required parameters +**** +> Integer representing the number of weeks to be reduced (positive number means reduction, negative number means increase). -The parameter date can be DATETIME or DATE, and the return type is consistent with that of the parameter date. +## Optional parameters +- **** + > Date input value of type `DATE` -### example +- **** + > Date and time input value of type `DATETIME` -``` -mysql> select weeks_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| weeks_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-01-26 02:02:02 | -+-------------------------------------+ -``` -### keywords +## Example + +1. Subtract one week from the datetime `2020-02-02 02:02:02` + ```sql + select weeks_sub("2020-02-02 02:02:02", 1); + ``` + ```text + +-------------------------------------+ + | weeks_sub('2020-02-02 02:02:02', 1) | + +-------------------------------------+ + | 2020-01-26 02:02:02 | + +-------------------------------------+ + ``` - WEEKS_SUB +2. Subtract one week from the date `2020-02-02` + ```sql + select weeks_sub("2020-02-02", 1); + ``` + ```text + +--------------------------------------------+ + | weeks_sub(cast('2020-02-02' as DATEV2), 1) | + +--------------------------------------------+ + | 2020-01-26 | + +--------------------------------------------+ + ``` \ No newline at end of file From a9231e348b85d8af55260e28863c6c1e40ba04e4 Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Wed, 19 Mar 2025 15:12:16 +0800 Subject: [PATCH 07/13] fix_to_date --- .../scalar-functions/date-time-functions/to-date.md | 7 +++++-- .../scalar-functions/date-time-functions/to-date.md | 7 +++++-- .../scalar-functions/date-time-functions/to-date.md | 11 +++++++---- .../scalar-functions/date-time-functions/to-date.md | 7 +++++-- .../scalar-functions/date-time-functions/to-date.md | 7 +++++-- .../scalar-functions/date-time-functions/to-date.md | 6 ++++-- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index d6f6897d6ef4f..6b8353ac77e80 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -26,7 +26,7 @@ under the License. ## Description -Date conversion function, used to convert a date time string or timestamp to a date type (DATE), that is, remove the time part and keep only the date (YYYY-MM-DD) +Date conversion function, used to convert date time (DATETIME) to date type (DATE), that is, remove the time part and keep only the date (YYYY-MM-DD) ## Syntax ```sql @@ -34,7 +34,10 @@ TO_DATE() ``` ## Required parameter -**datetime_value**: datetime type datetime +| Parameter | Description | +|-----------------|--------------------------| +| `datetime_value` | DATETIME type date-time | + ## Example diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index ec31bee63d99c..b307968150b04 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -25,7 +25,7 @@ under the License. --> ## 描述 -日期转换函数,用于将日期时间字符串或时间戳 转换为 日期类型(DATE),即去掉时间部分,仅保留日期(YYYY-MM-DD) +日期转换函数,用于将日期时间(DATETIME)转换为日期类型(DATE),即去掉时间部分,仅保留日期(YYYY-MM-DD) ## 语法 ```sql @@ -33,7 +33,10 @@ TO_DATE() ``` ## 必选参数 -**datetime_value**:datetime 类型日期时间 +| 参数 | 描述 | +|------------------|--------------------| +| `datetime_value` | DATETIME 类型日期时间 | + ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index d11b68427c480..d6ecdf2ef6290 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -1,7 +1,7 @@ --- { - "title": "TO_DATE", - "language": "zh-CN" + "title": "TO_DATE", + "language": "zh-CN" } --- @@ -25,7 +25,7 @@ under the License. --> ## 描述 -日期转换函数,用于将日期时间字符串或时间戳 转换为 日期类型(DATE),即去掉时间部分,仅保留日期(YYYY-MM-DD) +日期转换函数,用于将日期时间(DATETIME)转换为日期类型(DATE),即去掉时间部分,仅保留日期(YYYY-MM-DD) ## 语法 ```sql @@ -33,7 +33,10 @@ TO_DATE() ``` ## 必选参数 -**datetime_value**:datetime 类型日期时间 +| 参数 | 描述 | +|------------------|--------------------| +| `datetime_value` | DATETIME 类型日期时间 | + ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index 5fba17a27d9fd..d6ecdf2ef6290 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -25,7 +25,7 @@ under the License. --> ## 描述 -日期转换函数,用于将日期时间字符串或时间戳 转换为 日期类型(DATE),即去掉时间部分,仅保留日期(YYYY-MM-DD) +日期转换函数,用于将日期时间(DATETIME)转换为日期类型(DATE),即去掉时间部分,仅保留日期(YYYY-MM-DD) ## 语法 ```sql @@ -33,7 +33,10 @@ TO_DATE() ``` ## 必选参数 -**datetime_value**:datetime 类型日期时间 +| 参数 | 描述 | +|------------------|--------------------| +| `datetime_value` | DATETIME 类型日期时间 | + ## 举例 diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index 552b5ee25ce08..fd646744897e6 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -26,7 +26,7 @@ under the License. ## Description -Date conversion function, used to convert a date time string or timestamp to a date type (DATE), that is, remove the time part and keep only the date (YYYY-MM-DD) +Date conversion function, used to convert date time (DATETIME) to date type (DATE), that is, remove the time part and keep only the date (YYYY-MM-DD) ## Syntax ```sql @@ -34,7 +34,10 @@ TO_DATE() ``` ## Required parameter -**datetime_value**: datetime type datetime +| Parameter | Description | +|-----------------|--------------------------| +| `datetime_value` | DATETIME type date-time | + ## Example diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md index 552b5ee25ce08..9272f5c1db293 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-date.md @@ -26,7 +26,7 @@ under the License. ## Description -Date conversion function, used to convert a date time string or timestamp to a date type (DATE), that is, remove the time part and keep only the date (YYYY-MM-DD) +Date conversion function, used to convert date time (DATETIME) to date type (DATE), that is, remove the time part and keep only the date (YYYY-MM-DD) ## Syntax ```sql @@ -34,7 +34,9 @@ TO_DATE() ``` ## Required parameter -**datetime_value**: datetime type datetime +| Parameter | Description | +|-----------------|--------------------------| +| `datetime_value` | DATETIME type date-time | ## Example From ecc1042a4170e57e8384bcf64227fafb8457bdf3 Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Wed, 19 Mar 2025 15:17:36 +0800 Subject: [PATCH 08/13] fix_WEEKS_DIFF --- .../date-time-functions/weeks-diff.md | 14 ++++++-------- .../date-time-functions/weeks-diff.md | 18 ++++++++---------- .../date-time-functions/weeks-diff.md | 18 ++++++++---------- .../date-time-functions/weeks-diff.md | 14 ++++++-------- .../date-time-functions/weeks-diff.md | 18 ++++++++---------- .../date-time-functions/weeks-diff.md | 18 ++++++++---------- 6 files changed, 44 insertions(+), 56 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index 95b67292ba584..a7f949cc2dbfe 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -30,16 +30,14 @@ Calculates the number of complete weeks (in 7-day units) between two date or tim ## Syntax ```sql -WEEKS_DIFF([ | ], [ | ]) +WEEKS_DIFF(, ) ``` -## Optional parameters -| Parameter name | Data type | Description | -|----------------------|------------|----------------------| -| **`end_date`** | `DATE` | Later date | -| **`end_datetime`** | `DATETIME` | Later datetime | -| **`start_date`** | `DATE` | Earlier date | -| **`start_datetime`** | `DATETIME` | Earlier datetime | +## Required parameters +| Parameter Name | Data Type | Description | +|---------------|----------------------|-----------------------------| +| `end_date` | `DATE`, `DATETIME` | Later date or date-time | +| `start_date` | `DATE`, `DATETIME` | Earlier date or date-time | ## Example diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index d257d63a3622e..5c422870408f2 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_DIFF", - "language": "zh-CN" + "title": "WEEKS_DIFF", + "language": "zh-CN" } --- @@ -30,16 +30,14 @@ under the License. ## 语法 ```sql -WEEKS_DIFF([ | ], [ | ]) +WEEKS_DIFF(, ) ``` -## 可选参数 -| 参数名称 | 数据类型 | 描述 | -|----------------------|------------|----------------------| -| **`end_date`** | `DATE` | 较晚的日期 | -| **`end_datetime`** | `DATETIME` | 较晚的日期时间 | -| **`start_date`** | `DATE` | 较早的日期 | -| **`start_datetime`** | `DATETIME` | 较早的日期时间 | +## 必选参数 +| 参数名称 | 数据类型 | 描述 | +|--------------|--------------------|-------------| +| `end_date` | `DATE`, `DATETIME` | 较晚的日期或者日期时间 | +| `start_date` | `DATE`, `DATETIME` | 较早的日期或者日期时间 | ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index 6155c8a3546f9..5c422870408f2 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_DIFF", - "language": "zh-CN" + "title": "WEEKS_DIFF", + "language": "zh-CN" } --- @@ -30,16 +30,14 @@ under the License. ## 语法 ```sql -WEEKS_DIFF([ | ], [ | ]) +WEEKS_DIFF(, ) ``` -## 可选参数 -| 参数名称 | 数据类型 | 描述 | -|----------------------|------------|----------------------| -| **`end_date`** | `DATE` | 较晚的日期 | -| **`end_datetime`** | `DATETIME` | 较晚的日期时间 | -| **`start_date`** | `DATE` | 较早的日期 | -| **`start_datetime`** | `DATETIME` | 较早的日期时间 | +## 必选参数 +| 参数名称 | 数据类型 | 描述 | +|--------------|--------------------|-------------| +| `end_date` | `DATE`, `DATETIME` | 较晚的日期或者日期时间 | +| `start_date` | `DATE`, `DATETIME` | 较早的日期或者日期时间 | ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index 6155c8a3546f9..3e05224b0a254 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -30,16 +30,14 @@ under the License. ## 语法 ```sql -WEEKS_DIFF([ | ], [ | ]) +WEEKS_DIFF(, ) ``` -## 可选参数 -| 参数名称 | 数据类型 | 描述 | -|----------------------|------------|----------------------| -| **`end_date`** | `DATE` | 较晚的日期 | -| **`end_datetime`** | `DATETIME` | 较晚的日期时间 | -| **`start_date`** | `DATE` | 较早的日期 | -| **`start_datetime`** | `DATETIME` | 较早的日期时间 | +## 必选参数 +| 参数名称 | 数据类型 | 描述 | +|--------------|--------------------|-------------| +| `end_date` | `DATE`, `DATETIME` | 较晚的日期或者日期时间 | +| `start_date` | `DATE`, `DATETIME` | 较早的日期或者日期时间 | ## 举例 diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index 16687572b78ce..a69221380bc71 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_DIFF", - "language": "en" + "title": "WEEKS_DIFF", + "language": "en" } --- @@ -30,16 +30,14 @@ Calculates the number of complete weeks (in 7-day units) between two date or tim ## Syntax ```sql -WEEKS_DIFF([ | ], [ | ]) +WEEKS_DIFF(, ) ``` -## Optional parameters -| Parameter name | Data type | Description | -|----------------------|------------|----------------------| -| **`end_date`** | `DATE` | Later date | -| **`end_datetime`** | `DATETIME` | Later datetime | -| **`start_date`** | `DATE` | Earlier date | -| **`start_datetime`** | `DATETIME` | Earlier datetime | +## Required parameters +| Parameter Name | Data Type | Description | +|---------------|----------------------|-----------------------------| +| `end_date` | `DATE`, `DATETIME` | Later date or date-time | +| `start_date` | `DATE`, `DATETIME` | Earlier date or date-time | ## Example diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md index 16687572b78ce..a69221380bc71 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-diff.md @@ -1,7 +1,7 @@ --- { - "title": "WEEKS_DIFF", - "language": "en" + "title": "WEEKS_DIFF", + "language": "en" } --- @@ -30,16 +30,14 @@ Calculates the number of complete weeks (in 7-day units) between two date or tim ## Syntax ```sql -WEEKS_DIFF([ | ], [ | ]) +WEEKS_DIFF(, ) ``` -## Optional parameters -| Parameter name | Data type | Description | -|----------------------|------------|----------------------| -| **`end_date`** | `DATE` | Later date | -| **`end_datetime`** | `DATETIME` | Later datetime | -| **`start_date`** | `DATE` | Earlier date | -| **`start_datetime`** | `DATETIME` | Earlier datetime | +## Required parameters +| Parameter Name | Data Type | Description | +|---------------|----------------------|-----------------------------| +| `end_date` | `DATE`, `DATETIME` | Later date or date-time | +| `start_date` | `DATE`, `DATETIME` | Earlier date or date-time | ## Example From eae380b2b379277d1322320450b153c6d1c3509a Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Wed, 19 Mar 2025 15:26:01 +0800 Subject: [PATCH 09/13] fix_WEEKS_SUB --- .../date-time-functions/weeks-sub.md | 18 ++++++++---------- .../date-time-functions/weeks-sub.md | 15 +++++---------- .../date-time-functions/weeks-sub.md | 15 +++++---------- .../date-time-functions/weeks-sub.md | 15 +++++---------- .../date-time-functions/weeks-sub.md | 18 ++++++++---------- .../date-time-functions/weeks-sub.md | 18 ++++++++---------- 6 files changed, 39 insertions(+), 60 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index c09205eab59a3..2799b76674d1c 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -26,21 +26,19 @@ under the License. ## Description +Subtracts a specified number of weeks from a specified date or time value (i.e., subtracts weeks * 7 days). + ## Syntax ```sql -WEEKS_SUB([ | ], ) +WEEKS_SUB(, ) ``` ## Required parameters -**** -> Integer representing the number of weeks to be reduced (positive number means reduction, negative number means increase). - -## Optional parameters -- **** - > Date input value of type `DATE` - -- **** - > Date and time input value of type `DATETIME` +## 必选参数 +| Parameter | Description | +|-----------------|-----------------------------------------------------------------------------------------------------| +| `date_value` | `DATE` or `DATETIME` type input value. | +| `week_period` | Integer, representing the number of weeks to subtract (positive to decrease, negative to increase). | ## Example diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 4829d1e4c4461..99f2f9e43130d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -29,19 +29,14 @@ under the License. ## 语法 ```sql -WEEKS_SUB([ | ], ) +WEEKS_SUB(, ) ``` ## 必选参数 -**** -> 整数,表示要减少的周数(正数表示减少,负数表示增加)。 - -## 可选参数 -- **** - > `DATE` 类型的日期输入值 - -- **** - > `DATETIME` 类型的日期时间输入值 +| 参数名称 | 描述 | +|---------------|-------------------------------------------------------------------| +| `date_value` | `DATE` 或 `DATETIME` 类型的输入值。 | +| `week_period` | 整数,表示要减少的周数(正数表示减少,负数表示增加)。 | ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 8252376ff56f1..a04993cdcf2bf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -29,19 +29,14 @@ under the License. ## 语法 ```sql -WEEKS_SUB([ | ], ) +WEEKS_SUB(, ) ``` ## 必选参数 -**** -> 整数,表示要减少的周数(正数表示减少,负数表示增加)。 - -## 可选参数 -- **** - > `DATE` 类型的日期输入值 - -- **** - > `DATETIME` 类型的日期时间输入值 +| 参数名称 | 描述 | +|---------------|-------------------------------------------------------------------| +| `date_value` | `DATE` 或 `DATETIME` 类型的输入值。 | +| `week_period` | 整数,表示要减少的周数(正数表示减少,负数表示增加)。 | ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 8252376ff56f1..a04993cdcf2bf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -29,19 +29,14 @@ under the License. ## 语法 ```sql -WEEKS_SUB([ | ], ) +WEEKS_SUB(, ) ``` ## 必选参数 -**** -> 整数,表示要减少的周数(正数表示减少,负数表示增加)。 - -## 可选参数 -- **** - > `DATE` 类型的日期输入值 - -- **** - > `DATETIME` 类型的日期时间输入值 +| 参数名称 | 描述 | +|---------------|-------------------------------------------------------------------| +| `date_value` | `DATE` 或 `DATETIME` 类型的输入值。 | +| `week_period` | 整数,表示要减少的周数(正数表示减少,负数表示增加)。 | ## 举例 diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 76270571c7d98..fe7fa63f74a3c 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -26,21 +26,19 @@ under the License. ## Description +Subtracts a specified number of weeks from a specified date or time value (i.e., subtracts weeks * 7 days). + ## Syntax ```sql -WEEKS_SUB([ | ], ) +WEEKS_SUB(, ) ``` ## Required parameters -**** -> Integer representing the number of weeks to be reduced (positive number means reduction, negative number means increase). - -## Optional parameters -- **** - > Date input value of type `DATE` - -- **** - > Date and time input value of type `DATETIME` +## 必选参数 +| Parameter | Description | +|-----------------|-----------------------------------------------------------------------------------------------------| +| `date_value` | `DATE` or `DATETIME` type input value. | +| `week_period` | Integer, representing the number of weeks to subtract (positive to decrease, negative to increase). | ## Example diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 76270571c7d98..fe7fa63f74a3c 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -26,21 +26,19 @@ under the License. ## Description +Subtracts a specified number of weeks from a specified date or time value (i.e., subtracts weeks * 7 days). + ## Syntax ```sql -WEEKS_SUB([ | ], ) +WEEKS_SUB(, ) ``` ## Required parameters -**** -> Integer representing the number of weeks to be reduced (positive number means reduction, negative number means increase). - -## Optional parameters -- **** - > Date input value of type `DATE` - -- **** - > Date and time input value of type `DATETIME` +## 必选参数 +| Parameter | Description | +|-----------------|-----------------------------------------------------------------------------------------------------| +| `date_value` | `DATE` or `DATETIME` type input value. | +| `week_period` | Integer, representing the number of weeks to subtract (positive to decrease, negative to increase). | ## Example From 188b8ff943a18e893f2e849f159c25d3540d4a84 Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Wed, 19 Mar 2025 15:36:39 +0800 Subject: [PATCH 10/13] fix_year_floor --- .../date-time-functions/year-floor.md | 20 +++++++--------- .../date-time-functions/year-floor.md | 20 +++++++--------- .../date-time-functions/year-floor.md | 24 ++++++++----------- .../date-time-functions/year-floor.md | 24 ++++++++----------- .../date-time-functions/year-floor.md | 24 ++++++++----------- .../date-time-functions/year-floor.md | 24 ++++++++----------- 6 files changed, 56 insertions(+), 80 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index d1c4bb3ba141c..a7c1c045221f4 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -31,20 +31,16 @@ It is used to round the given date down to the specified year interval starting ## Syntax ```sql -YEAR_FLOOR([ | ]) | -YEAR_FLOOR([ | ], []) | -YEAR_FLOOR([ | ], ) | -YEAR_FLOOR([ | ], , []) +YEAR_FLOOR(, [ | ]) +YEAR_FLOOR(, , ) ``` -## Optional Parameters -| **Parameter** | **Type** | **Description** | -|-----------------------------|------------|---------------------------------------------------------| -| `` | `DATETIME` | The `DATETIME` value to be floored. | -| `` | `DATE` | The `DATE` value to be floored. | -| `` | `DATETIME` | The `DATETIME` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | -| `` | `DATE` | The `DATE` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | -| `` | `INT` | The time interval, a positive integer, specifying the number of years to floor by. | +## Parameters +| **Parameter** | **Type** | **Description** | +|--------------------------|----------------------|--------------------------------------------------------------------------------------------------------------------------| +| `` | `DATE`, `DATETIME` | The `DATE` or `DATETIME` input value to be rounded. | +| `` | `DATE`, `DATETIME` | The `DATE` or `DATETIME` input value used as the reference point. If not provided, the default is `0001-01-01T00:00:00`. | +| `` | `INT` | The rounding interval, a positive integer indicating the number of years per cycle. | ## Example diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index 455d0b2898cc6..bed658c2bc4d3 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -29,20 +29,16 @@ under the License. ## 语法 ```sql -YEAR_FLOOR([ | ]) | -YEAR_FLOOR([ | ], []) | -YEAR_FLOOR([ | ], ) | -YEAR_FLOOR([ | ], , []) +YEAR_FLOOR(, [ | ]) +YEAR_FLOOR(, , ) ``` -## 可选参数 -| **参数** | **类型** | **说明** | -|-----------------------------|------------|---------------------------------------------------| -| `` | `DATETIME` | 需要取整的 `DATETIME` 日期时间 | -| `` | `DATE` | 需要取整的 `DATE` 日期 | -| `` | `DATETIME` | 用作基准的 `DATETIME` 日期, 如果不填,默认是 0001-01-01T00:00:00 | -| `` | `DATE` | 用作基准的 `DATE` 日期, 如果不填,默认是 0001-01-01T00:00:00 | -| `` | `INT` | 取整的时间间隔,正整数,表示以多少年为周期进行取整。 | +## 参数 +| **参数** | **类型** | **说明** | +|----------------------|--------------------|--------------------------------------------------------------------| +| `` | `DATE`, `DATETIME` | 需要取整的 `DATE` 或 `DATETIME` 输入值。 | +| `` | `DATE`, `DATETIME` | 用作基准的 `DATE` 或 `DATETIME` 输入值,如果不填,默认值为 `0001-01-01T00:00:00`。 | +| `` | `INT` | 取整的时间间隔,正整数,表示以多少年为周期进行取整。 | ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index dc3eb5c8603d7..83ce5a5490e08 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -1,7 +1,7 @@ --- { - "title": "year_floor", - "language": "zh-CN" + "title": "year_floor", + "language": "zh-CN" } --- @@ -29,20 +29,16 @@ under the License. ## 语法 ```sql -YEAR_FLOOR([ | ]) | -YEAR_FLOOR([ | ], []) | -YEAR_FLOOR([ | ], ) | -YEAR_FLOOR([ | ], , []) +YEAR_FLOOR(, [ | ]) +YEAR_FLOOR(, , ) ``` -## 可选参数 -| **参数** | **类型** | **说明** | -|-----------------------------|------------|---------------------------------------------------| -| `` | `DATETIME` | 需要取整的 `DATETIME` 日期时间 | -| `` | `DATE` | 需要取整的 `DATE` 日期 | -| `` | `DATETIME` | 用作基准的 `DATETIME` 日期, 如果不填,默认是 0001-01-01T00:00:00 | -| `` | `DATE` | 用作基准的 `DATE` 日期, 如果不填,默认是 0001-01-01T00:00:00 | -| `` | `INT` | 取整的时间间隔,正整数,表示以多少年为周期进行取整。 | +## 参数 +| **参数** | **类型** | **说明** | +|----------------------|--------------------|--------------------------------------------------------------------| +| `` | `DATE`, `DATETIME` | 需要取整的 `DATE` 或 `DATETIME` 输入值。 | +| `` | `DATE`, `DATETIME` | 用作基准的 `DATE` 或 `DATETIME` 输入值,如果不填,默认值为 `0001-01-01T00:00:00`。 | +| `` | `INT` | 取整的时间间隔,正整数,表示以多少年为周期进行取整。 | ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index dc3eb5c8603d7..83ce5a5490e08 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -1,7 +1,7 @@ --- { - "title": "year_floor", - "language": "zh-CN" + "title": "year_floor", + "language": "zh-CN" } --- @@ -29,20 +29,16 @@ under the License. ## 语法 ```sql -YEAR_FLOOR([ | ]) | -YEAR_FLOOR([ | ], []) | -YEAR_FLOOR([ | ], ) | -YEAR_FLOOR([ | ], , []) +YEAR_FLOOR(, [ | ]) +YEAR_FLOOR(, , ) ``` -## 可选参数 -| **参数** | **类型** | **说明** | -|-----------------------------|------------|---------------------------------------------------| -| `` | `DATETIME` | 需要取整的 `DATETIME` 日期时间 | -| `` | `DATE` | 需要取整的 `DATE` 日期 | -| `` | `DATETIME` | 用作基准的 `DATETIME` 日期, 如果不填,默认是 0001-01-01T00:00:00 | -| `` | `DATE` | 用作基准的 `DATE` 日期, 如果不填,默认是 0001-01-01T00:00:00 | -| `` | `INT` | 取整的时间间隔,正整数,表示以多少年为周期进行取整。 | +## 参数 +| **参数** | **类型** | **说明** | +|----------------------|--------------------|--------------------------------------------------------------------| +| `` | `DATE`, `DATETIME` | 需要取整的 `DATE` 或 `DATETIME` 输入值。 | +| `` | `DATE`, `DATETIME` | 用作基准的 `DATE` 或 `DATETIME` 输入值,如果不填,默认值为 `0001-01-01T00:00:00`。 | +| `` | `INT` | 取整的时间间隔,正整数,表示以多少年为周期进行取整。 | ## 举例 diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index ece9af9ff80e5..31e57b9692fd5 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -1,7 +1,7 @@ --- { - "title": "year_floor", - "language": "en" + "title": "year_floor", + "language": "en" } --- @@ -31,20 +31,16 @@ It is used to round the given date down to the specified year interval starting ## Syntax ```sql -YEAR_FLOOR([ | ]) | -YEAR_FLOOR([ | ], []) | -YEAR_FLOOR([ | ], ) | -YEAR_FLOOR([ | ], , []) +YEAR_FLOOR(, [ | ]) +YEAR_FLOOR(, , ) ``` -## Optional Parameters -| **Parameter** | **Type** | **Description** | -|-----------------------------|------------|---------------------------------------------------------| -| `` | `DATETIME` | The `DATETIME` value to be floored. | -| `` | `DATE` | The `DATE` value to be floored. | -| `` | `DATETIME` | The `DATETIME` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | -| `` | `DATE` | The `DATE` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | -| `` | `INT` | The time interval, a positive integer, specifying the number of years to floor by. | +## Parameters +| **Parameter** | **Type** | **Description** | +|--------------------------|----------------------|--------------------------------------------------------------------------------------------------------------------------| +| `` | `DATE`, `DATETIME` | The `DATE` or `DATETIME` input value to be rounded. | +| `` | `DATE`, `DATETIME` | The `DATE` or `DATETIME` input value used as the reference point. If not provided, the default is `0001-01-01T00:00:00`. | +| `` | `INT` | The rounding interval, a positive integer indicating the number of years per cycle. | ## Example diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md index ece9af9ff80e5..31e57b9692fd5 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/year-floor.md @@ -1,7 +1,7 @@ --- { - "title": "year_floor", - "language": "en" + "title": "year_floor", + "language": "en" } --- @@ -31,20 +31,16 @@ It is used to round the given date down to the specified year interval starting ## Syntax ```sql -YEAR_FLOOR([ | ]) | -YEAR_FLOOR([ | ], []) | -YEAR_FLOOR([ | ], ) | -YEAR_FLOOR([ | ], , []) +YEAR_FLOOR(, [ | ]) +YEAR_FLOOR(, , ) ``` -## Optional Parameters -| **Parameter** | **Type** | **Description** | -|-----------------------------|------------|---------------------------------------------------------| -| `` | `DATETIME` | The `DATETIME` value to be floored. | -| `` | `DATE` | The `DATE` value to be floored. | -| `` | `DATETIME` | The `DATETIME` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | -| `` | `DATE` | The `DATE` value used as the reference. If not specified, defaults to `0001-01-01T00:00:00`. | -| `` | `INT` | The time interval, a positive integer, specifying the number of years to floor by. | +## Parameters +| **Parameter** | **Type** | **Description** | +|--------------------------|----------------------|--------------------------------------------------------------------------------------------------------------------------| +| `` | `DATE`, `DATETIME` | The `DATE` or `DATETIME` input value to be rounded. | +| `` | `DATE`, `DATETIME` | The `DATE` or `DATETIME` input value used as the reference point. If not provided, the default is `0001-01-01T00:00:00`. | +| `` | `INT` | The rounding interval, a positive integer indicating the number of years per cycle. | ## Example From bb0a4e5b1e63bd3f92f1881d73d2a293e09623cb Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Mon, 31 Mar 2025 15:46:16 +0800 Subject: [PATCH 11/13] fix WEEKS_SUB --- .../scalar-functions/date-time-functions/weeks-sub.md | 1 - .../scalar-functions/date-time-functions/weeks-sub.md | 1 - .../scalar-functions/date-time-functions/weeks-sub.md | 1 - 3 files changed, 3 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index 2799b76674d1c..f8ed6b096db21 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -34,7 +34,6 @@ WEEKS_SUB(, ) ``` ## Required parameters -## 必选参数 | Parameter | Description | |-----------------|-----------------------------------------------------------------------------------------------------| | `date_value` | `DATE` or `DATETIME` type input value. | diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index fe7fa63f74a3c..07c721b1bde63 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -34,7 +34,6 @@ WEEKS_SUB(, ) ``` ## Required parameters -## 必选参数 | Parameter | Description | |-----------------|-----------------------------------------------------------------------------------------------------| | `date_value` | `DATE` or `DATETIME` type input value. | diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md index fe7fa63f74a3c..07c721b1bde63 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-sub.md @@ -34,7 +34,6 @@ WEEKS_SUB(, ) ``` ## Required parameters -## 必选参数 | Parameter | Description | |-----------------|-----------------------------------------------------------------------------------------------------| | `date_value` | `DATE` or `DATETIME` type input value. | From 3e4fd40cc37dd46210d6894e586f5c7b8b0b1f4f Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Mon, 31 Mar 2025 15:50:32 +0800 Subject: [PATCH 12/13] fix TO_DAYS --- .../scalar-functions/date-time-functions/to-days.md | 9 ++++----- .../scalar-functions/date-time-functions/to-days.md | 9 ++++----- .../scalar-functions/date-time-functions/to-days.md | 13 ++++++------- .../scalar-functions/date-time-functions/to-days.md | 13 ++++++------- .../scalar-functions/date-time-functions/to-days.md | 9 ++++----- .../scalar-functions/date-time-functions/to-days.md | 9 ++++----- 6 files changed, 28 insertions(+), 34 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 03c77ba0ef3f3..618a05db8498d 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 @@ -35,11 +35,10 @@ TO_DAYS([ | ]) ``` ## Optional parameters -1. **** -> datetime type datetime - -2. **** -> date type datetime +| Parameter | Description | +|------------------|------------------------| +| `` | `datetime` type date-time | +| `` | `date` type date-time | ## Example 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 b442c6678ab47..5f3846be5f00f 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 @@ -35,11 +35,10 @@ TO_DAYS([ | ]) ``` ## 可选参数 -1. **** - > datetime 类型日期时间 - -2. **** - > date 类型日期时间 +| 参数 | 描述 | +|-----------------|-----------------------| +| `` | `datetime` 类型日期时间 | +| `` | `date` 类型日期时间 | ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md index 27bbfcfe63cf6..5e7467914641a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md @@ -1,7 +1,7 @@ --- { - "title": "TO_DAYS", - "language": "zh-CN" + "title": "TO_DAYS", + "language": "zh-CN" } --- @@ -35,11 +35,10 @@ TO_DAYS([ | ]) ``` ## 可选参数 -1. **** - > datetime 类型日期时间 - -2. **** - > date 类型日期时间 +| 参数 | 描述 | +|-----------------|-----------------------| +| `` | `datetime` 类型日期时间 | +| `` | `date` 类型日期时间 | ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md index 27bbfcfe63cf6..5e7467914641a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md @@ -1,7 +1,7 @@ --- { - "title": "TO_DAYS", - "language": "zh-CN" + "title": "TO_DAYS", + "language": "zh-CN" } --- @@ -35,11 +35,10 @@ TO_DAYS([ | ]) ``` ## 可选参数 -1. **** - > datetime 类型日期时间 - -2. **** - > date 类型日期时间 +| 参数 | 描述 | +|-----------------|-----------------------| +| `` | `datetime` 类型日期时间 | +| `` | `date` 类型日期时间 | ## 举例 diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md index d13250f242cc7..dcaa466b67ce0 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md @@ -35,11 +35,10 @@ TO_DAYS([ | ]) ``` ## Optional parameters -1. **** -> datetime type datetime - -2. **** -> date type datetime +| Parameter | Description | +|------------------|------------------------| +| `` | `datetime` type date-time | +| `` | `date` type date-time | ## Example diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md index d13250f242cc7..dcaa466b67ce0 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/to-days.md @@ -35,11 +35,10 @@ TO_DAYS([ | ]) ``` ## Optional parameters -1. **** -> datetime type datetime - -2. **** -> date type datetime +| Parameter | Description | +|------------------|------------------------| +| `` | `datetime` type date-time | +| `` | `date` type date-time | ## Example From 084ac46335d4952b8cb40d57631ae82708f3a537 Mon Sep 17 00:00:00 2001 From: DongLiang-0 <1747644936@qq.com> Date: Mon, 31 Mar 2025 15:53:38 +0800 Subject: [PATCH 13/13] fix WEEKS_ADD --- .../date-time-functions/weeks-add.md | 13 +++++++------ .../date-time-functions/weeks-add.md | 14 +++++++------- .../date-time-functions/weeks-add.md | 14 +++++++------- .../date-time-functions/weeks-add.md | 14 +++++++------- .../date-time-functions/weeks-add.md | 13 +++++++------ .../date-time-functions/weeks-add.md | 13 +++++++------ 6 files changed, 42 insertions(+), 39 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index 2f9e938445717..9bd6c1d167211 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -34,15 +34,16 @@ WEEKS_ADD([ | ], ) ``` ## Required parameters -**** -> Integer, indicating the number of weeks to increase or decrease (positive number indicates increase, negative number indicates decrease) +| Parameter | Description | +|--------------|---------------------------------------------------------------| +| `` | Integer, indicating the number of weeks to increase or decrease (positive number indicates increase, negative number indicates decrease) | ## Optional parameters -- **** - > `DATE` date type input value +| Parameter | Description | +|------------------|--------------------------------| +| `` | `DATE` type date input value | +| `` | `DATETIME` type time input value | -- **** - > `DATETIME` time type input value ## example diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index 50fe77c82c83b..fcbb8545efc7d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -33,15 +33,15 @@ WEEKS_ADD([ | ], ) ``` ## 必选参数 -**** -> 整数,表示要增加或减少的周数(正数表示增加,负数表示减少) +| 参数 | 描述 | +|--------------|----------------------------------------| +| `` | 整数,表示要增加或减少的周数(正数表示增加,负数表示减少) | ## 可选参数 -- **** - > `DATE` 日期类型的输入值 - -- **** - > `DATETIME` 时间类型的输入值 +| 参数 | 描述 | +|-----------------|------------------------| +| `` | `DATE` 日期类型的输入值 | +| `` | `DATETIME` 时间类型的输入值 | ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index fe40cc765a35d..78d61afa6f1e9 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -33,15 +33,15 @@ WEEKS_ADD([ | ], ) ``` ## 必选参数 -**** -> 整数,表示要增加或减少的周数(正数表示增加,负数表示减少) +| 参数 | 描述 | +|--------------|----------------------------------------| +| `` | 整数,表示要增加或减少的周数(正数表示增加,负数表示减少) | ## 可选参数 -- **** - > `DATE` 日期类型的输入值 - -- **** - > `DATETIME` 时间类型的输入值 +| 参数 | 描述 | +|-----------------|------------------------| +| `` | `DATE` 日期类型的输入值 | +| `` | `DATETIME` 时间类型的输入值 | ## 举例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index fe40cc765a35d..78d61afa6f1e9 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -33,15 +33,15 @@ WEEKS_ADD([ | ], ) ``` ## 必选参数 -**** -> 整数,表示要增加或减少的周数(正数表示增加,负数表示减少) +| 参数 | 描述 | +|--------------|----------------------------------------| +| `` | 整数,表示要增加或减少的周数(正数表示增加,负数表示减少) | ## 可选参数 -- **** - > `DATE` 日期类型的输入值 - -- **** - > `DATETIME` 时间类型的输入值 +| 参数 | 描述 | +|-----------------|------------------------| +| `` | `DATE` 日期类型的输入值 | +| `` | `DATETIME` 时间类型的输入值 | ## 举例 diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index 765f77832ec9d..d1fa9896f0bff 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -34,15 +34,16 @@ WEEKS_ADD([ | ], ) ``` ## Required parameters -**** -> Integer, indicating the number of weeks to increase or decrease (positive number indicates increase, negative number indicates decrease) +| Parameter | Description | +|--------------|---------------------------------------------------------------| +| `` | Integer, indicating the number of weeks to increase or decrease (positive number indicates increase, negative number indicates decrease) | ## Optional parameters -- **** - > `DATE` date type input value +| Parameter | Description | +|------------------|--------------------------------| +| `` | `DATE` type date input value | +| `` | `DATETIME` type time input value | -- **** - > `DATETIME` time type input value ## example diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md index 765f77832ec9d..d1fa9896f0bff 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/weeks-add.md @@ -34,15 +34,16 @@ WEEKS_ADD([ | ], ) ``` ## Required parameters -**** -> Integer, indicating the number of weeks to increase or decrease (positive number indicates increase, negative number indicates decrease) +| Parameter | Description | +|--------------|---------------------------------------------------------------| +| `` | Integer, indicating the number of weeks to increase or decrease (positive number indicates increase, negative number indicates decrease) | ## Optional parameters -- **** - > `DATE` date type input value +| Parameter | Description | +|------------------|--------------------------------| +| `` | `DATE` type date input value | +| `` | `DATETIME` type time input value | -- **** - > `DATETIME` time type input value ## example