From 0ccef11824c7db9f627d12657ac06eae86f35607 Mon Sep 17 00:00:00 2001 From: stdpain Date: Wed, 25 Dec 2024 11:17:34 +0800 Subject: [PATCH 1/4] [Doc] add doc for time_format Signed-off-by: stdpain --- .../date-time-functions/time_format.md | 43 +++++++++++++++++++ .../date-time-functions/time_format.md | 43 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 docs/en/sql-reference/sql-functions/date-time-functions/time_format.md create mode 100644 docs/zh/sql-reference/sql-functions/date-time-functions/time_format.md diff --git a/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md b/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md new file mode 100644 index 0000000000000..d08a8d9d9349a --- /dev/null +++ b/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md @@ -0,0 +1,43 @@ +--- +displayed_sidebar: docs +--- + +# time_format + + + +The TIME_FORMAT() function formats the time in the specified format. + +* The `date` parameter is a legal date. +* `format` Specifies the output format of the date/time. + +The formats that can be used are: + +```Plain Text +%f Microseconds (000000 to 999999) +%H Hour (00 to 23) +%h Hour (00 to 12) +%i Minutes (00 to 59) +%p AM or PM +%S Seconds (00 to 59) +%s Seconds (00 to 59) +``` + +## Syntax + +```Haskell +VARCHAR TIME_FORMAT(TIME time, VARCHAR format) +``` + +## Examples + +```Plain Text +mysql> SELECT TIME_FORMAT("19:30:10", "%h %i %s %p"); ++----------------------------------------+ +| time_format('19:30:10', '%h %i %s %p') | ++----------------------------------------+ +| 12 00 00 AM | ++----------------------------------------+ +1 row in set (0.01 sec) + +``` diff --git a/docs/zh/sql-reference/sql-functions/date-time-functions/time_format.md b/docs/zh/sql-reference/sql-functions/date-time-functions/time_format.md new file mode 100644 index 0000000000000..4d998c74c003b --- /dev/null +++ b/docs/zh/sql-reference/sql-functions/date-time-functions/time_format.md @@ -0,0 +1,43 @@ +--- +displayed_sidebar: docs +--- + +# time_format + + + +TIME_FORMAT() 函数按指定格式格式化时间。 + +* `date` 参数是合法的日期。 +* `format` 指定日期/时间的输出格式。 + +可以使用的格式有: + +```Plain Text +%f Microseconds (000000 to 999999) +%H Hour (00 to 23) +%h Hour (00 to 12) +%i Minutes (00 to 59) +%p AM or PM +%S Seconds (00 to 59) +%s Seconds (00 to 59) +``` + +## 语法 + +```Haskell +VARCHAR TIME_FORMAT(TIME time, VARCHAR format) +``` + +## 示例 + +```Plain Text +mysql> SELECT TIME_FORMAT("19:30:10", "%h %i %s %p"); ++----------------------------------------+ +| time_format('19:30:10', '%h %i %s %p') | ++----------------------------------------+ +| 12 00 00 AM | ++----------------------------------------+ +1 row in set (0.01 sec) + +``` From 8c0261e608506b6e260b37143113b8364b43bfc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B5=B5=E7=A9=BA=E4=BA=8B=E3=82=B9=E3=83=94=E3=83=AA?= =?UTF-8?q?=E3=83=83=E3=83=88?= Date: Tue, 31 Dec 2024 16:01:02 +0800 Subject: [PATCH 2/4] Update time_format.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 絵空事スピリット --- .../date-time-functions/time_format.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md b/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md index d08a8d9d9349a..76b959d9ec94c 100644 --- a/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md +++ b/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md @@ -6,12 +6,18 @@ displayed_sidebar: docs -The TIME_FORMAT() function formats the time in the specified format. +Formats TIME-type values in the specified format. -* The `date` parameter is a legal date. -* `format` Specifies the output format of the date/time. +## Syntax + +```Haskell +VARCHAR TIME_FORMAT(TIME time, VARCHAR format) +``` + +## Parameters -The formats that can be used are: +- `time` (Required): The time to be formatted. +- `format` (Required): The format to use. Valid values: ```Plain Text %f Microseconds (000000 to 999999) @@ -23,12 +29,6 @@ The formats that can be used are: %s Seconds (00 to 59) ``` -## Syntax - -```Haskell -VARCHAR TIME_FORMAT(TIME time, VARCHAR format) -``` - ## Examples ```Plain Text From aa2c138a9ca3eabdbc67c67c54b59df671a48a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B5=B5=E7=A9=BA=E4=BA=8B=E3=82=B9=E3=83=94=E3=83=AA?= =?UTF-8?q?=E3=83=83=E3=83=88?= Date: Tue, 31 Dec 2024 16:11:32 +0800 Subject: [PATCH 3/4] Update time_format.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 絵空事スピリット --- .../date-time-functions/time_format.md | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/zh/sql-reference/sql-functions/date-time-functions/time_format.md b/docs/zh/sql-reference/sql-functions/date-time-functions/time_format.md index 4d998c74c003b..1b1be9e7c8be5 100644 --- a/docs/zh/sql-reference/sql-functions/date-time-functions/time_format.md +++ b/docs/zh/sql-reference/sql-functions/date-time-functions/time_format.md @@ -6,28 +6,29 @@ displayed_sidebar: docs -TIME_FORMAT() 函数按指定格式格式化时间。 +按指定格式格式化 TIME 类型时间值。 -* `date` 参数是合法的日期。 -* `format` 指定日期/时间的输出格式。 +## 语法 + +```Haskell +VARCHAR TIME_FORMAT(TIME time, VARCHAR format) +``` + +## 参数说明 -可以使用的格式有: +- `time`(必须):待格式化的 TIME 类型时间值。 +- `format`(必须):要使用的输出格式。有效值: ```Plain Text -%f Microseconds (000000 to 999999) -%H Hour (00 to 23) -%h Hour (00 to 12) -%i Minutes (00 to 59) +%f Microseconds (000000 至 999999) +%H Hour (00 至 23) +%h Hour (00 至 12) +%i Minutes (00 至 59) %p AM or PM -%S Seconds (00 to 59) -%s Seconds (00 to 59) +%S Seconds (00 至 59) +%s Seconds (00 至 59) ``` -## 语法 - -```Haskell -VARCHAR TIME_FORMAT(TIME time, VARCHAR format) -``` ## 示例 @@ -39,5 +40,4 @@ mysql> SELECT TIME_FORMAT("19:30:10", "%h %i %s %p"); | 12 00 00 AM | +----------------------------------------+ 1 row in set (0.01 sec) - ``` From f1650e28b2df6d9419bd9f42c3ece3db09ada0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B5=B5=E7=A9=BA=E4=BA=8B=E3=82=B9=E3=83=94=E3=83=AA?= =?UTF-8?q?=E3=83=83=E3=83=88?= Date: Tue, 31 Dec 2024 16:12:44 +0800 Subject: [PATCH 4/4] Update time_format.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 絵空事スピリット --- .../sql-functions/date-time-functions/time_format.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md b/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md index 76b959d9ec94c..77c9ffb6f6ae6 100644 --- a/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md +++ b/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md @@ -16,7 +16,7 @@ VARCHAR TIME_FORMAT(TIME time, VARCHAR format) ## Parameters -- `time` (Required): The time to be formatted. +- `time` (Required): The time value (of the TIME type) to be formatted. - `format` (Required): The format to use. Valid values: ```Plain Text