From 9b70836b6c2b7f90ed04c41f90ad9ba3473dbe59 Mon Sep 17 00:00:00 2001 From: Victor Krasnov Date: Fri, 9 Jun 2023 16:07:07 +0300 Subject: [PATCH] Add a syslog format example to the documentation --- .../functions/type-conversion-functions.md | 22 +++++++++++++++++++ .../functions/type-conversion-functions.md | 22 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/docs/en/sql-reference/functions/type-conversion-functions.md b/docs/en/sql-reference/functions/type-conversion-functions.md index f1e2785285c..9c079bd9515 100644 --- a/docs/en/sql-reference/functions/type-conversion-functions.md +++ b/docs/en/sql-reference/functions/type-conversion-functions.md @@ -1428,6 +1428,28 @@ Result: └──────┴─────────────────────────────────────┘ ``` +Query: + +``` sql +WITH + now() AS ts_now, + formatDateTime(ts_around, '%b %e %T') AS syslog_arg +SELECT + ts_now, + syslog_arg, + parseDateTimeBestEffort(syslog_arg) +FROM (SELECT arrayJoin([ts_now - 30, ts_now + 30]) AS ts_around); +``` + +Result: + +```response +┌──────────────ts_now─┬─syslog_arg──────┬─parseDateTimeBestEffort(syslog_arg)─┐ +│ 2023-06-09 16:04:30 │ Jun 9 16:04:00 │ 2023-06-09 16:04:00 │ +│ 2023-06-09 16:04:30 │ Jun 9 16:05:00 │ 2022-06-09 16:05:00 │ +└─────────────────────┴─────────────────┴─────────────────────────────────────┘ +``` + **See Also** - [RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123) diff --git a/docs/ru/sql-reference/functions/type-conversion-functions.md b/docs/ru/sql-reference/functions/type-conversion-functions.md index b763ee2b3ac..6e93a5e0acf 100644 --- a/docs/ru/sql-reference/functions/type-conversion-functions.md +++ b/docs/ru/sql-reference/functions/type-conversion-functions.md @@ -1107,6 +1107,28 @@ SELECT toYear(now()) as year, parseDateTimeBestEffort('10 20:19'); └──────┴─────────────────────────────────────┘ ``` +Запрос: + +``` sql +WITH + now() AS ts_now, + formatDateTime(ts_around, '%b %e %T') AS syslog_arg +SELECT + ts_now, + syslog_arg, + parseDateTimeBestEffort(syslog_arg) +FROM (SELECT arrayJoin([ts_now - 30, ts_now + 30]) AS ts_around); +``` + +Результат: + +``` text +┌──────────────ts_now─┬─syslog_arg──────┬─parseDateTimeBestEffort(syslog_arg)─┐ +│ 2023-06-09 16:04:30 │ Jun 9 16:04:00 │ 2023-06-09 16:04:00 │ +│ 2023-06-09 16:04:30 │ Jun 9 16:05:00 │ 2022-06-09 16:05:00 │ +└─────────────────────┴─────────────────┴─────────────────────────────────────┘ +``` + **Смотрите также** - [Информация о формате ISO 8601 от @xkcd](https://xkcd.com/1179/)