Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ If the `period` parameter is negative or its month part is invalid, the function

## Examples

<!-- setup-sql
CREATE TABLE test_period_add (period BIGINT, month BIGINT) DISTRIBUTED BY HASH(period) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_period_add VALUES (200803,2),(200809,5),(803,2),(6910,3),(7001,1),(12345611,123456),(NULL,10),(202510,NULL);
-->

```sql
SELECT `period`, `month`, PERIOD_ADD(`period`, `month`) AS ans FROM test_period_add;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ If the parameters are negative or their month parts are invalid, the function wi

## Examples

<!-- setup-sql
CREATE TABLE test_period_diff (period_1 LARGEINT, period_2 LARGEINT) DISTRIBUTED BY HASH(period_1) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_period_diff VALUES (200802,200703),(200703,200802),(7001,6912),(NULL,2510),(2510,NULL),(9223372036854775807,101),(9223372036854775808,101);
-->

```sql
SELECT `period_1`, `period_2`, PERIOD_DIFF(`period_1`, `period_2`) AS DIFF FROM `test_period_diff`;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ Special cases:

## Examples

<!-- setup-sql
CREATE TABLE test_time_format (id INT, tm VARCHAR(30)) DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_time_format VALUES (1,'00:00:00'),(2,'00:00:00.123456'),(3,'12:34:56'),(4,'12:34:56.789012'),(5,'23:59:59'),(6,'23:59:59.999999'),(7,'08:00:00'),(8,'15:00:00'),(9,'100:00:00'),(10,'123:45:56'),(11,'838:59:59.999999'),(12,'-00:00:01'),(13,'-12:34:56.000001'),(14,'-838:59:59.999999');
CREATE TABLE test_format (fmt VARCHAR(10)) DISTRIBUTED BY HASH(fmt) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_format VALUES ('%Y'),('%y'),('%m'),('%d'),('%c'),('%e');
-->

```sql
SELECT * FROM test_time_format;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ PERIOD_ADD(`<period>`, `<month>`)

## 举例

<!-- setup-sql
CREATE TABLE test_period_add (period BIGINT, month BIGINT) DISTRIBUTED BY HASH(period) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_period_add VALUES (200803,2),(200809,5),(803,2),(6910,3),(7001,1),(12345611,123456),(NULL,10),(202510,NULL);
-->

```sql
SELECT `period`, `month`, PERIOD_ADD(`period`, `month`) AS ans FROM test_period_add;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ PERIOD_DIFF(`<period_1>`, `<period_2>`)

## 举例

<!-- setup-sql
CREATE TABLE test_period_diff (period_1 LARGEINT, period_2 LARGEINT) DISTRIBUTED BY HASH(period_1) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_period_diff VALUES (200802,200703),(200703,200802),(7001,6912),(NULL,2510),(2510,NULL),(9223372036854775807,101),(9223372036854775808,101);
-->

```sql
SELECT `period_1`, `period_2`, PERIOD_DIFF(`period_1`, `period_2`) AS DIFF FROM `test_period_diff`;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ TIME_FORMAT(<time_or_datetime_expr>, <format>)

## 举例

<!-- setup-sql
CREATE TABLE test_time_format (id INT, tm VARCHAR(30)) DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_time_format VALUES (1,'00:00:00'),(2,'00:00:00.123456'),(3,'12:34:56'),(4,'12:34:56.789012'),(5,'23:59:59'),(6,'23:59:59.999999'),(7,'08:00:00'),(8,'15:00:00'),(9,'100:00:00'),(10,'123:45:56'),(11,'838:59:59.999999'),(12,'-00:00:01'),(13,'-12:34:56.000001'),(14,'-838:59:59.999999');
CREATE TABLE test_format (fmt VARCHAR(10)) DISTRIBUTED BY HASH(fmt) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_format VALUES ('%Y'),('%y'),('%m'),('%d'),('%c'),('%e');
-->

```sql
SELECT * FROM test_time_format;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
---

## 描述

Check warning on line 9 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-add.md

View workflow job for this annotation

GitHub Actions / Build Check

markdown-cjk-spacing

Chinese text should contain spaces around adjacent English words or numbers. Owner%3A @zclllyybb
计算周期 `<period>`增加 `<month>` 个月的结果。

其中 `<period>` 是一个整数,最后两位表示月份(01-12),前面的数字表示年份。
Expand All @@ -15,7 +15,7 @@
若年份部分小于 100 会按[一定规则](#参数)补为四位数年份格式处理。
如: PERIOD_ADD(2501, 0) 会返回 202501, 而不是2501。

该函数与 MySQL 的 [PERIOD_ADD 函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_period-add) 行为一致。

Check notice on line 18 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-add.md

View workflow job for this annotation

GitHub Actions / Build Check

link-external-report-only

External link is report-only and was not fetched%3A https%3A//dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_period-add. Owner%3A @zclllyybb

## 语法

Expand All @@ -25,7 +25,7 @@

## 参数

| 参数 | 说明 |

Check warning on line 28 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-add.md

View workflow job for this annotation

GitHub Actions / Build Check

markdown-cjk-spacing

Chinese text should contain spaces around adjacent English words or numbers. Owner%3A @zclllyybb
|---------------|-------------------------------------------------------|
| `<period>` | 代表一个由年和月组成的周期。<ul><li>**格式**:月份固定占末尾两位,必须在 `[1, 12]` 范围内。前面的数字表示年份,年份位数不限,可以超过四位。</li><li>**年份推断**:年份取值直接使用除最后两位外的所有数字。当年份为两位数(范围:[00, 99]), 此时若年份小于 70 则解读为 20YY,若大于等于 70 则解读为 19YY。</li><li>**值范围**:接受 `[0, 2^63-1]` 范围内的整型参数。</li></ul> |
| `<month>` | 在 `<period>` 基础上需要增加的月份数。接受 `[-2^63, 2^63-1]` 范围内的整型。 |
Expand All @@ -40,6 +40,11 @@

## 举例

<!-- setup-sql
CREATE TABLE test_period_add (period BIGINT, month BIGINT) DISTRIBUTED BY HASH(period) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_period_add VALUES (200803,2),(200809,5),(803,2),(6910,3),(7001,1),(12345611,123456),(NULL,10),(202510,NULL);
-->

```sql
SELECT `period`, `month`, PERIOD_ADD(`period`, `month`) AS ans FROM test_period_add;
```
Expand Down Expand Up @@ -71,7 +76,7 @@
```sql
SELECT PERIOD_ADD(9223372036854775807, 1);
```
```text

Check warning on line 79 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-add.md

View workflow job for this annotation

GitHub Actions / Build Check

markdown-cjk-spacing

Chinese text should contain spaces around adjacent English words or numbers. Owner%3A @zclllyybb
+------------------------------------+
| PERIOD_ADD(9223372036854775807, 1) |
+------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "PERIOD_DIFF",
"language": "zh-CN",
"description": "计算两个周期之间的月份差值。"
}

Check warning on line 6 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-diff.md

View workflow job for this annotation

GitHub Actions / Build Check

markdown-cjk-spacing

Chinese text should contain spaces around adjacent English words or numbers. Owner%3A @zclllyybb
---

## 描述
Expand All @@ -14,7 +14,7 @@

若年份部分小于 100 会按[一定规则](#参数)补为四位数年份格式处理。

该函数与 MySQL 的 [PERIOD_DIFF 函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_period-diff) 行为一致。

Check notice on line 17 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-diff.md

View workflow job for this annotation

GitHub Actions / Build Check

link-external-report-only

External link is report-only and was not fetched%3A https%3A//dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_period-diff. Owner%3A @zclllyybb

## 语法

Expand All @@ -39,6 +39,11 @@

## 举例

<!-- setup-sql
CREATE TABLE test_period_diff (period_1 LARGEINT, period_2 LARGEINT) DISTRIBUTED BY HASH(period_1) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_period_diff VALUES (200802,200703),(200703,200802),(7001,6912),(NULL,2510),(2510,NULL),(9223372036854775807,101),(9223372036854775808,101);
-->

```sql
SELECT `period_1`, `period_2`, PERIOD_DIFF(`period_1`, `period_2`) AS DIFF FROM `test_period_diff`;
```
Expand All @@ -48,7 +53,7 @@
+---------------------+----------+---------------------+
| 200802 | 200703 | 11 |
| 200703 | 200802 | -11 |
| 7001 | 6912 | -1199 |

Check warning on line 56 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-diff.md

View workflow job for this annotation

GitHub Actions / Build Check

markdown-cjk-spacing

Chinese text should contain spaces around adjacent English words or numbers. Owner%3A @zclllyybb
| NULL | 2510 | NULL |
| 2510 | NULL | NULL |
| 9223372036854775807 | 101 | 1106804644422549090 |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/time-format.md

View workflow job for this annotation

GitHub Actions / Build Check

frontmatter-description-required

Missing required front matter field%3A description. Owner%3A @zclllyybb
{
"title": "TIME_FORMAT",
"language": "zh-CN"
Expand All @@ -9,7 +9,7 @@

TIME_FORMAT 函数用于将时间值按照指定的格式字符串(format)转换为字符串。支持对 TIME 和 DATETIME 类型进行格式化,输出结果为符合格式要求的字符串。

该函数与 mysql 中的 [time_format 函数](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_time-format) 行为一致。

Check notice on line 12 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/time-format.md

View workflow job for this annotation

GitHub Actions / Build Check

link-external-report-only

External link is report-only and was not fetched%3A https%3A//dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_time-format. Owner%3A @zclllyybb

## 语法

Expand Down Expand Up @@ -57,6 +57,13 @@

## 举例

<!-- setup-sql
CREATE TABLE test_time_format (id INT, tm VARCHAR(30)) DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_time_format VALUES (1,'00:00:00'),(2,'00:00:00.123456'),(3,'12:34:56'),(4,'12:34:56.789012'),(5,'23:59:59'),(6,'23:59:59.999999'),(7,'08:00:00'),(8,'15:00:00'),(9,'100:00:00'),(10,'123:45:56'),(11,'838:59:59.999999'),(12,'-00:00:01'),(13,'-12:34:56.000001'),(14,'-838:59:59.999999');
CREATE TABLE test_format (fmt VARCHAR(10)) DISTRIBUTED BY HASH(fmt) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_format VALUES ('%Y'),('%y'),('%m'),('%d'),('%c'),('%e');
-->

```sql
SELECT * FROM test_time_format;
```
Expand Down Expand Up @@ -120,12 +127,12 @@
| 9 | 100:00:00 | 100 | 100 | 04 | 04 | 4 | 00 | 00 | 00 | 000000 | AM | 04:00:00 AM | 100:00:00 | 100:00:00.000000 | 100 100 4 04 04 | 100:00:00 04:00:00 AM 04:04 | 4 100 04 100 04 AM | 000000 00 00 100:00:00 04:00:00 AM |
| 10 | 123:45:56 | 123 | 123 | 03 | 03 | 3 | 45 | 56 | 56 | 000000 | AM | 03:45:56 AM | 123:45:56 | 123:45:56.000000 | 123 123 3 03 03 | 123:45:56 03:45:56 AM 03:03 | 3 123 03 123 03 AM | 000000 56 45 123:45:56 03:45:56 AM |
| 11 | 838:59:59.999999 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| 12 | -00:00:01 | -00 | -0 | -12 | -12 | -12 | -00 | -01 | -01 | -000000 | -AM | -12:00:01 AM | -00:00:01 | -00:00:01.000000 | -0 00 12 12 12 | -00:00:01 12:00:01 AM 12:12 | -12 0 12 00 12 AM | -000000 01 00 00:00:01 12:00:01 AM |

Check warning on line 130 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/time-format.md

View workflow job for this annotation

GitHub Actions / Build Check

markdown-code-fence-language

Code fence should declare a language. Owner%3A @zclllyybb
| 13 | -12:34:56.000001 | -12 | -12 | -12 | -12 | -12 | -34 | -56 | -56 | -000001 | -PM | -12:34:56 PM | -12:34:56 | -12:34:56.000001 | -12 12 12 12 12 | -12:34:56 12:34:56 PM 12:12 | -12 12 12 12 12 PM | -000001 56 34 12:34:56 12:34:56 PM |
| 14 | -838:59:59.999999 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
+------+-------------------+------+------+------+------+------+------+------+------+---------+------+--------------+-----------+------------------+-----------------+-----------------------------+--------------------+------------------------------------+

Check warning on line 133 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/time-format.md

View workflow job for this annotation

GitHub Actions / Build Check

markdown-cjk-spacing

Chinese text should contain spaces around adjacent English words or numbers. Owner%3A @zclllyybb
```
> 注: 对于参数 `838:59:59.999999` 和 `-838:59:59.999999`, 由于超过了 TIME 的范围[-838:59:59, 838:59:59] 无法转换为 TIME 类型,故返回结果为 NULL

Check warning on line 135 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/time-format.md

View workflow job for this annotation

GitHub Actions / Build Check

markdown-code-fence-language

Code fence should declare a language. Owner%3A @zclllyybb
```

```sql
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check notice on line 1 in versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-add.md

View workflow job for this annotation

GitHub Actions / Build Check

i18n-sync-locale-candidate

Japanese docs are report-only. Generate a candidate translation from the changed files and merge it only after human review. Owner%3A @zclllyybb
{
"title": "PERIOD_ADD",
"language": "en",
Expand All @@ -15,7 +15,7 @@
If the year part is less than 100, it will be processed into a four-digit year format according to [certain rules](#parameters).
For example: PERIOD_ADD(2501, 0) will return 202501, not 2501.

This function behaves consistently with MySQL's [PERIOD_ADD function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_period-add).

Check notice on line 18 in versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-add.md

View workflow job for this annotation

GitHub Actions / Build Check

link-external-report-only

External link is report-only and was not fetched%3A https%3A//dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_period-add. Owner%3A @zclllyybb

## Syntax

Expand All @@ -40,6 +40,11 @@

## Examples

<!-- setup-sql
CREATE TABLE test_period_add (period BIGINT, month BIGINT) DISTRIBUTED BY HASH(period) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_period_add VALUES (200803,2),(200809,5),(803,2),(6910,3),(7001,1),(12345611,123456),(NULL,10),(202510,NULL);
-->

```sql
SELECT `period`, `month`, PERIOD_ADD(`period`, `month`) AS ans FROM test_period_add;
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check notice on line 1 in versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-diff.md

View workflow job for this annotation

GitHub Actions / Build Check

i18n-sync-locale-candidate

Japanese docs are report-only. Generate a candidate translation from the changed files and merge it only after human review. Owner%3A @zclllyybb
{
"title": "PERIOD_DIFF",
"language": "en",
Expand All @@ -14,7 +14,7 @@

If the year part is less than 100, it will be converted to a four-digit year format according to [certain rules](#parameters).

This function behaves consistently with MySQL's [PERIOD_DIFF function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_period-diff).

Check notice on line 17 in versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/period-diff.md

View workflow job for this annotation

GitHub Actions / Build Check

link-external-report-only

External link is report-only and was not fetched%3A https%3A//dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_period-diff. Owner%3A @zclllyybb

## Syntax

Expand All @@ -39,6 +39,11 @@

## Examples

<!-- setup-sql
CREATE TABLE test_period_diff (period_1 LARGEINT, period_2 LARGEINT) DISTRIBUTED BY HASH(period_1) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_period_diff VALUES (200802,200703),(200703,200802),(7001,6912),(NULL,2510),(2510,NULL),(9223372036854775807,101),(9223372036854775808,101);
-->

```sql
SELECT `period_1`, `period_2`, PERIOD_DIFF(`period_1`, `period_2`) AS DIFF FROM `test_period_diff`;
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check notice on line 1 in versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/time-format.md

View workflow job for this annotation

GitHub Actions / Build Check

i18n-sync-locale-candidate

Japanese docs are report-only. Generate a candidate translation from the changed files and merge it only after human review. Owner%3A @zclllyybb

Check warning on line 1 in versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/time-format.md

View workflow job for this annotation

GitHub Actions / Build Check

frontmatter-description-required

Missing required front matter field%3A description. Owner%3A @zclllyybb
{
"title": "TIME_FORMAT",
"language": "en"
Expand All @@ -9,7 +9,7 @@

The TIME_FORMAT function is used to convert a time value into a string according to the specified format string. It supports formatting for TIME and DATETIME types, and the output is a string that conforms to the format requirements.

This function behaves consistently with the [time_format function](https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_time-format) in MySQL.

Check notice on line 12 in versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/date-time-functions/time-format.md

View workflow job for this annotation

GitHub Actions / Build Check

link-external-report-only

External link is report-only and was not fetched%3A https%3A//dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_time-format. Owner%3A @zclllyybb

## Syntax

Expand Down Expand Up @@ -57,6 +57,13 @@

## Examples

<!-- setup-sql
CREATE TABLE test_time_format (id INT, tm VARCHAR(30)) DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_time_format VALUES (1,'00:00:00'),(2,'00:00:00.123456'),(3,'12:34:56'),(4,'12:34:56.789012'),(5,'23:59:59'),(6,'23:59:59.999999'),(7,'08:00:00'),(8,'15:00:00'),(9,'100:00:00'),(10,'123:45:56'),(11,'838:59:59.999999'),(12,'-00:00:01'),(13,'-12:34:56.000001'),(14,'-838:59:59.999999');
CREATE TABLE test_format (fmt VARCHAR(10)) DISTRIBUTED BY HASH(fmt) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO test_format VALUES ('%Y'),('%y'),('%m'),('%d'),('%c'),('%e');
-->

```sql
SELECT * FROM test_time_format;
```
Expand Down
Loading