Функция timePart
позволяет выбрать из даты ее определенную часть. На выходе тип колонки будет числовой (unsigned).
timePart(колонка, 'формат')
Поддерживаемые форматы:
Запрос:
select
started,
timePart(started, 'year') AS "year",
timePart(started, 'month') AS "month",
timePart(started, 'day') AS "day",
timePart(started, 'hour') AS "hour",
timePart(started, 'minute') AS "minute",
timePart(started, 'second') AS "second",
timePart(started, 'weekday') AS "weekday",
timePart(started, 'dayofyear') AS "dayofyear"
from event
started |
---|
1627826406 |
1628130122 |
started | year | month | day | hour | minute | second | weekday | dayofyear |
---|---|---|---|---|---|---|---|---|
1627826406 | 2021 | 8 | 1 | 14 | 0 | 6 | 0 | 213 |
1628130122 | 2021 | 8 | 5 | 2 | 22 | 2 | 4 | 217 |