Add a syslog format example to the documentation

This commit is contained in:
Victor Krasnov 2023-06-09 16:07:07 +03:00
parent 3c1b02a37b
commit 9b70836b6c
2 changed files with 44 additions and 0 deletions

View File

@ -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)

View File

@ -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/)