From 2e298c8f2bddfa6ffc14b01c4108a0c2aaaadb66 Mon Sep 17 00:00:00 2001 From: stdpain <34912776+stdpain@users.noreply.github.com> Date: Fri, 3 Jan 2025 10:29:55 +0800 Subject: [PATCH] [Doc] add doc for time_format (#54300) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: stdpain Signed-off-by: 絵空事スピリット Co-authored-by: 絵空事スピリット --- .../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..77c9ffb6f6ae6 --- /dev/null +++ b/docs/en/sql-reference/sql-functions/date-time-functions/time_format.md @@ -0,0 +1,43 @@ +--- +displayed_sidebar: docs +--- + +# time_format + + + +Formats TIME-type values in the specified format. + +## Syntax + +```Haskell +VARCHAR TIME_FORMAT(TIME time, VARCHAR format) +``` + +## Parameters + +- `time` (Required): The time value (of the TIME type) to be formatted. +- `format` (Required): The format to use. Valid values: + +```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) +``` + +## 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..1b1be9e7c8be5 --- /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 类型时间值。 + +## 语法 + +```Haskell +VARCHAR TIME_FORMAT(TIME time, VARCHAR format) +``` + +## 参数说明 + +- `time`(必须):待格式化的 TIME 类型时间值。 +- `format`(必须):要使用的输出格式。有效值: + +```Plain Text +%f Microseconds (000000 至 999999) +%H Hour (00 至 23) +%h Hour (00 至 12) +%i Minutes (00 至 59) +%p AM or PM +%S Seconds (00 至 59) +%s Seconds (00 至 59) +``` + + +## 示例 + +```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) +```