This is an automated email from the ASF dual-hosted git repository. kassiez pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push: new 58c7250e255 [Fix](doc)Sql function quarter,quarters-add,quarters-sub (#1922) 58c7250e255 is described below commit 58c7250e255eaa613ac028449cdc4780d6aed9b2 Author: bingquanzhao <bingquan_z...@icloud.com> AuthorDate: Sat Feb 8 10:46:03 2025 +0800 [Fix](doc)Sql function quarter,quarters-add,quarters-sub (#1922) ## Versions - [x] dev - [x] 3.0 - [x] 2.1 - [x] 2.0 ## Languages - [x] Chinese - [x] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built --- .../date-time-functions/quarter.md | 47 ++++++++++++++-------- .../date-time-functions/quarters-add.md | 30 +++++++++----- .../date-time-functions/quarters-sub.md | 32 ++++++++++----- .../date-time-functions/quarter.md | 41 +++++++++++++------ .../date-time-functions/quarters-add.md | 29 ++++++++----- .../date-time-functions/quarters-sub.md | 30 +++++++++----- .../sql-functions/date-time-functions/quarter.md | 42 +++++++++++++------ .../date-time-functions/quarter.md | 42 +++++++++++++------ .../date-time-functions/quarter.md | 42 +++++++++++++------ .../date-time-functions/quarters-add.md | 29 ++++++++----- .../date-time-functions/quarters-sub.md | 30 +++++++++----- .../sql-functions/date-time-functions/quarter.md | 47 ++++++++++++++-------- .../date-time-functions/quarter.md | 47 ++++++++++++++-------- .../date-time-functions/quarter.md | 47 ++++++++++++++-------- .../date-time-functions/quarters-add.md | 32 ++++++++++----- .../date-time-functions/quarters-sub.md | 32 ++++++++++----- 16 files changed, 404 insertions(+), 195 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md index dc021ad6d5d..e07815e9a78 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md @@ -24,25 +24,40 @@ specific language governing permissions and limitations under the License. --> -## quarter -### description -#### Syntax +## Description +The function returns the quarter (1 to 4) of the given date. Each quarter includes three months: +- Q1: January to March +- Q2: April to June +- Q3: July to September +- Q4: October to December -`INT quarter(DATETIME date)` +## Syntax -Returns the quarter to which the specified date belongs, as an INT +```sql +QUARTER(<datetime>) +``` -### Example +## Parameters -``` -mysql> select quarter('2022-09-22 17:00:00'); -+--------------------------------+ -| quarter('2022-09-22 17:00:00') | -+--------------------------------+ -| 3 | -+--------------------------------+ -``` +| Parameter | Description | +|--------------|----------------------------------------------------------| +| `<datetime>` | A valid DATE or DATETIME value to determine the quarter. | -### keywords +## Return Value +- Returns an integer representing the quarter of the input date, ranging from 1 to 4. +- If the input is NULL, the function returns NULL. +- If the input is an invalid date (e.g., 0000-00-00), the function returns NULL. + +## Example + +```sql +SELECT QUARTER('2025-01-16'),QUARTER('2025-01-16 01:11:10'); +``` - quarter +```text ++-----------------------------------------+--------------------------------------------------+ +| quarter(cast('2025-01-16' as DATETIME)) | quarter(cast('2025-01-16 01:11:10' as DATETIME)) | ++-----------------------------------------+--------------------------------------------------+ +| 1 | 1 | ++-----------------------------------------+--------------------------------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md index 94f02780654..3cf47641b35 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md @@ -24,26 +24,36 @@ specific language governing permissions and limitations under the License. --> -### Description -#### Syntax +## Description +The function adds or subtracts a specified number of quarters to/from a given date or datetime value and returns the resulting date. -`DATE/DATETIME QUARTERS_ADD(DATE/DATETIME date, INT years)` +## Syntax -Add a specified number of quarters to a given date +```sql +QUARTERS_ADD(<date/datetime>, <quarters>) +``` + +## Parameters -The parameter `date` can be of type `DATETIME` or `DATE`, and the return type is the same as the type of the parameter `date`. +| Parameter | Description | +|-------------------|-----------------------------------------------------------------------------------------------------------------------| +| `<date/datetime>` | The input date or datetime value, supports DATE or DATETIME types. | +| `<quarters>` | The number of quarters to add or subtract. Positive integers add quarters, while negative integers subtract quarters. | + +## Return Value +- Returns a date value consistent with the input date type. +- If `<date/datetime>` is NULL, the function returns NULL. +- If `<date/datetime>` is an invalid date (e.g., 0000-00-00), the function returns NULL. ### Example ```sql -mysql> select quarters_add("2020-01-31 02:02:02", 1); + select quarters_add("2020-01-31 02:02:02", 1); +``` +```text +---------------------------------------------------------------+ | quarters_add(cast('2020-01-31 02:02:02' as DATETIMEV2(0)), 1) | +---------------------------------------------------------------+ | 2020-04-30 02:02:02 | +---------------------------------------------------------------+ -1 row in set (0.10 sec) ``` - -### keywords - QUARTERS, ADD, QUARTERS_ADD diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md index cab6ada0e81..b352bdb1c3d 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md @@ -24,26 +24,36 @@ specific language governing permissions and limitations under the License. --> -### Description -#### Syntax +## Description +The function adds or subtracts a specified number of quarters to/from a given date or datetime value and returns the resulting date. -`DATE/DATETIME QUARTERS_SUB(DATE/DATETIME date, INT years)` +## Syntax -Subtract a specified number of quarters for a given date +```sql +QUARTERS_SUB(<date/datetime>, <quarters>) +``` + +## Parameters + +| Parameter | Description | +|-------------------|-----------------------------------------------------------------------------------------------------------------------| +| `<date/datetime>` | The input date or datetime value, supports DATE or DATETIME types. | +| `<quarters>` | The number of quarters to add or subtract. Positive integers add quarters, while negative integers subtract quarters. | -The parameter `date` can be of type `DATETIME` or `DATE`, and the return type is the same as the type of the parameter `date`. +## Return Value +- Returns a date value consistent with the input date type. +- If `<date/datetime>` is NULL, the function returns NULL. +- If `<date/datetime>` is an invalid date (e.g., 0000-00-00), the function returns NULL. ### Example ```sql -mysql> select quarters_sub("2020-01-31 02:02:02", 1); + select quarters_sub("2020-01-31 02:02:02", 1); +``` +```text +---------------------------------------------------------------+ | quarters_sub(cast('2020-01-31 02:02:02' as DATETIMEV2(0)), 1) | +---------------------------------------------------------------+ | 2019-10-31 02:02:02 | +---------------------------------------------------------------+ -1 row in set (0.10 sec) -``` - -### keywords - QUARTERS, SUB, QUARTERS_SUB +``` \ 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/quarter.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md index d38d27ce1db..23231293ffd 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md @@ -24,25 +24,40 @@ specific language governing permissions and limitations under the License. --> -## quarter ## 描述 +函数用于返回指定 日期所属的季度(1 到 4)。每个季度包含三个月: +- 第 1 季度:1 月至 3 月 +- 第 2 季度:4 月至 6 月 +- 第 3 季度:7 月至 9 月 +- 第 4 季度:10 月至 12 月 + ## 语法 -`INT quarter(DATETIME date)` +```sql +QUARTER(<datetime>) +``` + +## 参数 -返回指定的日期所属季度,以INT类型返回 +| 参数 | 说明 | +|--------------|----------------------------------------| +| `<datetime>` | 输入的日期或日期时间值,必须是有效的 DATE 或 DATETIME 类型。 | + +## 返回值 +- 返回一个整数,表示输入日期所属的季度,范围为 1 到 4。 +- 如果输入值为 NULL,函数返回 NULL。 +- 如果输入值为非法日期(如 0000-00-00),函数返回 NULL。 ## 举例 +```sql +SELECT QUARTER('2025-01-16'),QUARTER('2025-01-16 01:11:10'); ``` -mysql> select quarter('2022-09-22 17:00:00'); -+--------------------------------+ -| quarter('2022-09-22 17:00:00') | -+--------------------------------+ -| 3 | -+--------------------------------+ -``` - -### keywords - quarter +```text ++-----------------------------------------+--------------------------------------------------+ +| quarter(cast('2025-01-16' as DATETIME)) | quarter(cast('2025-01-16 01:11:10' as DATETIME)) | ++-----------------------------------------+--------------------------------------------------+ +| 1 | 1 | ++-----------------------------------------+--------------------------------------------------+ +``` \ 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/quarters-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md index 62f731af5f3..1e1b67e65e2 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md @@ -25,25 +25,36 @@ under the License. --> ## 描述 +函数用于在指定的日期或日期时间值基础上,增加或减少指定的季度数,并返回计算后的日期值。 + ## 语法 -`DATE/DATETIME QUARTERS_ADD(DATE/DATETIME date, INT years)` +```sql +QUARTERS_ADD(<date/datetime>, <quarters>) +``` + +## 参数 -对给定日期加上指定数量的季度 +| 参数 | 说明 | +|-------------------|------------------------------------| +| `<date/datetime>` | 输入的日期或日期时间值,支持 DATE 或 DATETIME 类型。 | +| `<quarters>` | 要增加或减少的季度数,正整数表示增加,负整数表示减少。 | -参数 `date` 可以是 `DATETIME` 或者 `DATE` 类型,返回类型与参数 `date` 的类型一致。 +## 返回值 +- 返回一个日期值,与输入的日期类型一致。 +- 如果 `<date/datetime>` 为 NULL,函数返回 NULL。 +- 如果 `<date/datetime>` 为非法日期(如 0000-00-00),函数返回 NULL。 ## 举例 ```sql -mysql> select quarters_add("2020-01-31 02:02:02", 1); +select quarters_add("2020-01-31 02:02:02", 1); +``` + +```text +---------------------------------------------------------------+ | quarters_add(cast('2020-01-31 02:02:02' as DATETIMEV2(0)), 1) | +---------------------------------------------------------------+ | 2020-04-30 02:02:02 | +---------------------------------------------------------------+ -1 row in set (0.10 sec) -``` - -### keywords - QUARTERS, ADD, QUARTERS_ADD +``` \ 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/quarters-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md index 1c129864ac9..3a80e4c76c0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md @@ -25,24 +25,36 @@ under the License. --> ## 描述 +函数用于在指定的日期或日期时间值基础上,增加或减少指定的季度数,并返回计算后的日期值。 + ## 语法 -`DATE/DATETIME QUARTERS_SUB(DATE/DATETIME date, INT years)` +```sql +QUARTERS_SUB(<date/datetime>, <quarters>) +``` + +## 参数 + +| 参数 | 说明 | +|-------------------|------------------------------------| +| `<date/datetime>` | 输入的日期或日期时间值,支持 DATE 或 DATETIME 类型。 | +| `<quarters>` | 要增加或减少的季度数,正整数表示增加,负整数表示减少。 | -对给定日期减去指定数量的季度 +## 返回值 +- 返回一个日期值,与输入的日期类型一致。 +- 如果 `<date/datetime>` 为 NULL,函数返回 NULL。 +- 如果 `<date/datetime>` 为非法日期(如 0000-00-00),函数返回 NULL。 -参数 `date` 可以是 `DATETIME` 或者 `DATE` 类型,返回类型与参数 `date` 的类型一致。 ## 举例 ```sql -mysql> select quarters_sub("2020-01-31 02:02:02", 1); +select quarters_sub("2020-01-31 02:02:02", 1); +``` + +```text +---------------------------------------------------------------+ | quarters_sub(cast('2020-01-31 02:02:02' as DATETIMEV2(0)), 1) | +---------------------------------------------------------------+ | 2019-10-31 02:02:02 | +---------------------------------------------------------------+ -1 row in set (0.10 sec) -``` - -### keywords - QUARTERS, SUB, QUARTERS_SUB +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/date-time-functions/quarter.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/date-time-functions/quarter.md index d38d27ce1db..6456a39333d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/date-time-functions/quarter.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/date-time-functions/quarter.md @@ -24,25 +24,41 @@ specific language governing permissions and limitations under the License. --> -## quarter ## 描述 +函数用于返回指定 日期所属的季度(1 到 4)。每个季度包含三个月: +- 第 1 季度:1 月至 3 月 +- 第 2 季度:4 月至 6 月 +- 第 3 季度:7 月至 9 月 +- 第 4 季度:10 月至 12 月 + ## 语法 -`INT quarter(DATETIME date)` +```sql +QUARTER(<datetime>) +``` + +## 参数 + +| 参数 | 说明 | +|--------------|----------------------------------------| +| `<datetime>` | 输入的日期或日期时间值,必须是有效的 DATE 或 DATETIME 类型。 | -返回指定的日期所属季度,以INT类型返回 + +## 返回值 +- 返回一个整数,表示输入日期所属的季度,范围为 1 到 4。 +- 如果输入值为 NULL,函数返回 NULL。 +- 如果输入值为非法日期(如 0000-00-00),函数返回 NULL。 ## 举例 +```sql +SELECT QUARTER('2025-01-16'),QUARTER('2025-01-16 01:11:10'); ``` -mysql> select quarter('2022-09-22 17:00:00'); -+--------------------------------+ -| quarter('2022-09-22 17:00:00') | -+--------------------------------+ -| 3 | -+--------------------------------+ -``` - -### keywords - quarter +```text ++-----------------------------------------+--------------------------------------------------+ +| quarter(cast('2025-01-16' as DATETIME)) | quarter(cast('2025-01-16 01:11:10' as DATETIME)) | ++-----------------------------------------+--------------------------------------------------+ +| 1 | 1 | ++-----------------------------------------+--------------------------------------------------+ +``` \ 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/quarter.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md index d38d27ce1db..6456a39333d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md @@ -24,25 +24,41 @@ specific language governing permissions and limitations under the License. --> -## quarter ## 描述 +函数用于返回指定 日期所属的季度(1 到 4)。每个季度包含三个月: +- 第 1 季度:1 月至 3 月 +- 第 2 季度:4 月至 6 月 +- 第 3 季度:7 月至 9 月 +- 第 4 季度:10 月至 12 月 + ## 语法 -`INT quarter(DATETIME date)` +```sql +QUARTER(<datetime>) +``` + +## 参数 + +| 参数 | 说明 | +|--------------|----------------------------------------| +| `<datetime>` | 输入的日期或日期时间值,必须是有效的 DATE 或 DATETIME 类型。 | -返回指定的日期所属季度,以INT类型返回 + +## 返回值 +- 返回一个整数,表示输入日期所属的季度,范围为 1 到 4。 +- 如果输入值为 NULL,函数返回 NULL。 +- 如果输入值为非法日期(如 0000-00-00),函数返回 NULL。 ## 举例 +```sql +SELECT QUARTER('2025-01-16'),QUARTER('2025-01-16 01:11:10'); ``` -mysql> select quarter('2022-09-22 17:00:00'); -+--------------------------------+ -| quarter('2022-09-22 17:00:00') | -+--------------------------------+ -| 3 | -+--------------------------------+ -``` - -### keywords - quarter +```text ++-----------------------------------------+--------------------------------------------------+ +| quarter(cast('2025-01-16' as DATETIME)) | quarter(cast('2025-01-16 01:11:10' as DATETIME)) | ++-----------------------------------------+--------------------------------------------------+ +| 1 | 1 | ++-----------------------------------------+--------------------------------------------------+ +``` \ 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/quarter.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md index d38d27ce1db..6456a39333d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md @@ -24,25 +24,41 @@ specific language governing permissions and limitations under the License. --> -## quarter ## 描述 +函数用于返回指定 日期所属的季度(1 到 4)。每个季度包含三个月: +- 第 1 季度:1 月至 3 月 +- 第 2 季度:4 月至 6 月 +- 第 3 季度:7 月至 9 月 +- 第 4 季度:10 月至 12 月 + ## 语法 -`INT quarter(DATETIME date)` +```sql +QUARTER(<datetime>) +``` + +## 参数 + +| 参数 | 说明 | +|--------------|----------------------------------------| +| `<datetime>` | 输入的日期或日期时间值,必须是有效的 DATE 或 DATETIME 类型。 | -返回指定的日期所属季度,以INT类型返回 + +## 返回值 +- 返回一个整数,表示输入日期所属的季度,范围为 1 到 4。 +- 如果输入值为 NULL,函数返回 NULL。 +- 如果输入值为非法日期(如 0000-00-00),函数返回 NULL。 ## 举例 +```sql +SELECT QUARTER('2025-01-16'),QUARTER('2025-01-16 01:11:10'); ``` -mysql> select quarter('2022-09-22 17:00:00'); -+--------------------------------+ -| quarter('2022-09-22 17:00:00') | -+--------------------------------+ -| 3 | -+--------------------------------+ -``` - -### keywords - quarter +```text ++-----------------------------------------+--------------------------------------------------+ +| quarter(cast('2025-01-16' as DATETIME)) | quarter(cast('2025-01-16 01:11:10' as DATETIME)) | ++-----------------------------------------+--------------------------------------------------+ +| 1 | 1 | ++-----------------------------------------+--------------------------------------------------+ +``` \ 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/quarters-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md similarity index 60% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md index 62f731af5f3..1e1b67e65e2 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md @@ -25,25 +25,36 @@ under the License. --> ## 描述 +函数用于在指定的日期或日期时间值基础上,增加或减少指定的季度数,并返回计算后的日期值。 + ## 语法 -`DATE/DATETIME QUARTERS_ADD(DATE/DATETIME date, INT years)` +```sql +QUARTERS_ADD(<date/datetime>, <quarters>) +``` + +## 参数 -对给定日期加上指定数量的季度 +| 参数 | 说明 | +|-------------------|------------------------------------| +| `<date/datetime>` | 输入的日期或日期时间值,支持 DATE 或 DATETIME 类型。 | +| `<quarters>` | 要增加或减少的季度数,正整数表示增加,负整数表示减少。 | -参数 `date` 可以是 `DATETIME` 或者 `DATE` 类型,返回类型与参数 `date` 的类型一致。 +## 返回值 +- 返回一个日期值,与输入的日期类型一致。 +- 如果 `<date/datetime>` 为 NULL,函数返回 NULL。 +- 如果 `<date/datetime>` 为非法日期(如 0000-00-00),函数返回 NULL。 ## 举例 ```sql -mysql> select quarters_add("2020-01-31 02:02:02", 1); +select quarters_add("2020-01-31 02:02:02", 1); +``` + +```text +---------------------------------------------------------------+ | quarters_add(cast('2020-01-31 02:02:02' as DATETIMEV2(0)), 1) | +---------------------------------------------------------------+ | 2020-04-30 02:02:02 | +---------------------------------------------------------------+ -1 row in set (0.10 sec) -``` - -### keywords - QUARTERS, ADD, QUARTERS_ADD +``` \ 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/quarters-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md similarity index 59% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md index 1c129864ac9..3a80e4c76c0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md @@ -25,24 +25,36 @@ under the License. --> ## 描述 +函数用于在指定的日期或日期时间值基础上,增加或减少指定的季度数,并返回计算后的日期值。 + ## 语法 -`DATE/DATETIME QUARTERS_SUB(DATE/DATETIME date, INT years)` +```sql +QUARTERS_SUB(<date/datetime>, <quarters>) +``` + +## 参数 + +| 参数 | 说明 | +|-------------------|------------------------------------| +| `<date/datetime>` | 输入的日期或日期时间值,支持 DATE 或 DATETIME 类型。 | +| `<quarters>` | 要增加或减少的季度数,正整数表示增加,负整数表示减少。 | -对给定日期减去指定数量的季度 +## 返回值 +- 返回一个日期值,与输入的日期类型一致。 +- 如果 `<date/datetime>` 为 NULL,函数返回 NULL。 +- 如果 `<date/datetime>` 为非法日期(如 0000-00-00),函数返回 NULL。 -参数 `date` 可以是 `DATETIME` 或者 `DATE` 类型,返回类型与参数 `date` 的类型一致。 ## 举例 ```sql -mysql> select quarters_sub("2020-01-31 02:02:02", 1); +select quarters_sub("2020-01-31 02:02:02", 1); +``` + +```text +---------------------------------------------------------------+ | quarters_sub(cast('2020-01-31 02:02:02' as DATETIMEV2(0)), 1) | +---------------------------------------------------------------+ | 2019-10-31 02:02:02 | +---------------------------------------------------------------+ -1 row in set (0.10 sec) -``` - -### keywords - QUARTERS, SUB, QUARTERS_SUB +``` \ No newline at end of file diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/date-time-functions/quarter.md b/versioned_docs/version-2.0/sql-manual/sql-functions/date-time-functions/quarter.md index dc021ad6d5d..e07815e9a78 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/date-time-functions/quarter.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/date-time-functions/quarter.md @@ -24,25 +24,40 @@ specific language governing permissions and limitations under the License. --> -## quarter -### description -#### Syntax +## Description +The function returns the quarter (1 to 4) of the given date. Each quarter includes three months: +- Q1: January to March +- Q2: April to June +- Q3: July to September +- Q4: October to December -`INT quarter(DATETIME date)` +## Syntax -Returns the quarter to which the specified date belongs, as an INT +```sql +QUARTER(<datetime>) +``` -### Example +## Parameters -``` -mysql> select quarter('2022-09-22 17:00:00'); -+--------------------------------+ -| quarter('2022-09-22 17:00:00') | -+--------------------------------+ -| 3 | -+--------------------------------+ -``` +| Parameter | Description | +|--------------|----------------------------------------------------------| +| `<datetime>` | A valid DATE or DATETIME value to determine the quarter. | -### keywords +## Return Value +- Returns an integer representing the quarter of the input date, ranging from 1 to 4. +- If the input is NULL, the function returns NULL. +- If the input is an invalid date (e.g., 0000-00-00), the function returns NULL. + +## Example + +```sql +SELECT QUARTER('2025-01-16'),QUARTER('2025-01-16 01:11:10'); +``` - quarter +```text ++-----------------------------------------+--------------------------------------------------+ +| quarter(cast('2025-01-16' as DATETIME)) | quarter(cast('2025-01-16 01:11:10' as DATETIME)) | ++-----------------------------------------+--------------------------------------------------+ +| 1 | 1 | ++-----------------------------------------+--------------------------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md index dc021ad6d5d..e07815e9a78 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md @@ -24,25 +24,40 @@ specific language governing permissions and limitations under the License. --> -## quarter -### description -#### Syntax +## Description +The function returns the quarter (1 to 4) of the given date. Each quarter includes three months: +- Q1: January to March +- Q2: April to June +- Q3: July to September +- Q4: October to December -`INT quarter(DATETIME date)` +## Syntax -Returns the quarter to which the specified date belongs, as an INT +```sql +QUARTER(<datetime>) +``` -### Example +## Parameters -``` -mysql> select quarter('2022-09-22 17:00:00'); -+--------------------------------+ -| quarter('2022-09-22 17:00:00') | -+--------------------------------+ -| 3 | -+--------------------------------+ -``` +| Parameter | Description | +|--------------|----------------------------------------------------------| +| `<datetime>` | A valid DATE or DATETIME value to determine the quarter. | -### keywords +## Return Value +- Returns an integer representing the quarter of the input date, ranging from 1 to 4. +- If the input is NULL, the function returns NULL. +- If the input is an invalid date (e.g., 0000-00-00), the function returns NULL. + +## Example + +```sql +SELECT QUARTER('2025-01-16'),QUARTER('2025-01-16 01:11:10'); +``` - quarter +```text ++-----------------------------------------+--------------------------------------------------+ +| quarter(cast('2025-01-16' as DATETIME)) | quarter(cast('2025-01-16 01:11:10' as DATETIME)) | ++-----------------------------------------+--------------------------------------------------+ +| 1 | 1 | ++-----------------------------------------+--------------------------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md index dc021ad6d5d..e07815e9a78 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarter.md @@ -24,25 +24,40 @@ specific language governing permissions and limitations under the License. --> -## quarter -### description -#### Syntax +## Description +The function returns the quarter (1 to 4) of the given date. Each quarter includes three months: +- Q1: January to March +- Q2: April to June +- Q3: July to September +- Q4: October to December -`INT quarter(DATETIME date)` +## Syntax -Returns the quarter to which the specified date belongs, as an INT +```sql +QUARTER(<datetime>) +``` -### Example +## Parameters -``` -mysql> select quarter('2022-09-22 17:00:00'); -+--------------------------------+ -| quarter('2022-09-22 17:00:00') | -+--------------------------------+ -| 3 | -+--------------------------------+ -``` +| Parameter | Description | +|--------------|----------------------------------------------------------| +| `<datetime>` | A valid DATE or DATETIME value to determine the quarter. | -### keywords +## Return Value +- Returns an integer representing the quarter of the input date, ranging from 1 to 4. +- If the input is NULL, the function returns NULL. +- If the input is an invalid date (e.g., 0000-00-00), the function returns NULL. + +## Example + +```sql +SELECT QUARTER('2025-01-16'),QUARTER('2025-01-16 01:11:10'); +``` - quarter +```text ++-----------------------------------------+--------------------------------------------------+ +| quarter(cast('2025-01-16' as DATETIME)) | quarter(cast('2025-01-16 01:11:10' as DATETIME)) | ++-----------------------------------------+--------------------------------------------------+ +| 1 | 1 | ++-----------------------------------------+--------------------------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md index 94f02780654..94759f4971a 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-add.md @@ -24,26 +24,36 @@ specific language governing permissions and limitations under the License. --> -### Description -#### Syntax +## Description +The function adds or subtracts a specified number of quarters to/from a given date or datetime value and returns the resulting date. -`DATE/DATETIME QUARTERS_ADD(DATE/DATETIME date, INT years)` +## Syntax -Add a specified number of quarters to a given date +```sql +QUARTERS_ADD(<date/datetime>, <quarters>) +``` + +## Parameters + +| Parameter | Description | +|-------------------|-----------------------------------------------------------------------------------------------------------------------| +| `<date/datetime>` | The input date or datetime value, supports DATE or DATETIME types. | +| `<quarters>` | The number of quarters to add or subtract. Positive integers add quarters, while negative integers subtract quarters. | -The parameter `date` can be of type `DATETIME` or `DATE`, and the return type is the same as the type of the parameter `date`. +## Return Value +- Returns a date value consistent with the input date type. +- If <date/datetime> is NULL, the function returns NULL. +- If <date/datetime> is an invalid date (e.g., 0000-00-00), the function returns NULL. ### Example ```sql -mysql> select quarters_add("2020-01-31 02:02:02", 1); + select quarters_add("2020-01-31 02:02:02", 1); +``` +```text +---------------------------------------------------------------+ | quarters_add(cast('2020-01-31 02:02:02' as DATETIMEV2(0)), 1) | +---------------------------------------------------------------+ | 2020-04-30 02:02:02 | +---------------------------------------------------------------+ -1 row in set (0.10 sec) -``` - -### keywords - QUARTERS, ADD, QUARTERS_ADD +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md index cab6ada0e81..2cd5923d6c3 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/quarters-sub.md @@ -24,26 +24,36 @@ specific language governing permissions and limitations under the License. --> -### Description -#### Syntax +## Description +The function adds or subtracts a specified number of quarters to/from a given date or datetime value and returns the resulting date. -`DATE/DATETIME QUARTERS_SUB(DATE/DATETIME date, INT years)` +## Syntax -Subtract a specified number of quarters for a given date +```sql +QUARTERS_SUB(<date/datetime>, <quarters>) +``` + +## Parameters + +| Parameter | Description | +|-------------------|-----------------------------------------------------------------------------------------------------------------------| +| `<date/datetime>` | The input date or datetime value, supports DATE or DATETIME types. | +| `<quarters>` | The number of quarters to add or subtract. Positive integers add quarters, while negative integers subtract quarters. | -The parameter `date` can be of type `DATETIME` or `DATE`, and the return type is the same as the type of the parameter `date`. +## Return Value +- Returns a date value consistent with the input date type. +- If <date/datetime> is NULL, the function returns NULL. +- If <date/datetime> is an invalid date (e.g., 0000-00-00), the function returns NULL. ### Example ```sql -mysql> select quarters_sub("2020-01-31 02:02:02", 1); + select quarters_sub("2020-01-31 02:02:02", 1); +``` +```text +---------------------------------------------------------------+ | quarters_sub(cast('2020-01-31 02:02:02' as DATETIMEV2(0)), 1) | +---------------------------------------------------------------+ | 2019-10-31 02:02:02 | +---------------------------------------------------------------+ -1 row in set (0.10 sec) -``` - -### keywords - QUARTERS, SUB, QUARTERS_SUB +``` \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org