ClickHouse/tests/queries/0_stateless/01811_datename.sql

80 lines
3.6 KiB
MySQL
Raw Normal View History

2021-06-16 18:19:05 +00:00
WITH
toDate('2021-04-14') AS date_value,
2022-10-20 13:43:01 +00:00
toDate32('2021-04-14') AS date_32_value,
2021-06-16 18:19:05 +00:00
toDateTime('2021-04-14 11:22:33') AS date_time_value,
toDateTime64('2021-04-14 11:22:33', 3) AS date_time_64_value
2022-10-20 13:43:01 +00:00
SELECT dateName('year', date_value), dateName('year', date_32_value), dateName('year', date_time_value), dateName('year', date_time_64_value);
2021-06-16 18:19:05 +00:00
WITH
toDate('2021-04-14') AS date_value,
2022-10-20 13:43:01 +00:00
toDate32('2021-04-14') AS date_32_value,
2021-06-16 18:19:05 +00:00
toDateTime('2021-04-14 11:22:33') AS date_time_value,
toDateTime64('2021-04-14 11:22:33', 3) AS date_time_64_value
2022-10-20 13:43:01 +00:00
SELECT dateName('quarter', date_value), dateName('quarter', date_32_value), dateName('quarter', date_time_value), dateName('quarter', date_time_64_value);
2021-06-16 18:19:05 +00:00
WITH
toDate('2021-04-14') AS date_value,
2022-10-20 13:43:01 +00:00
toDate32('2021-04-14') AS date_32_value,
2021-06-16 18:19:05 +00:00
toDateTime('2021-04-14 11:22:33') AS date_time_value,
toDateTime64('2021-04-14 11:22:33', 3) AS date_time_64_value
2022-10-20 13:43:01 +00:00
SELECT dateName('month', date_value), dateName('month', date_32_value), dateName('month', date_time_value), dateName('month', date_time_64_value);
2021-06-16 18:19:05 +00:00
WITH
toDate('2021-04-14') AS date_value,
2022-10-20 13:43:01 +00:00
toDate32('2021-04-14') AS date_32_value,
2021-06-16 18:19:05 +00:00
toDateTime('2021-04-14 11:22:33') AS date_time_value,
toDateTime64('2021-04-14 11:22:33', 3) AS date_time_64_value
2022-10-20 13:43:01 +00:00
SELECT dateName('dayofyear', date_value), dateName('dayofyear', date_32_value), dateName('dayofyear', date_time_value), dateName('dayofyear', date_time_64_value);
2021-06-16 18:19:05 +00:00
WITH
toDate('2021-04-14') AS date_value,
2022-10-20 13:43:01 +00:00
toDate32('2021-04-14') AS date_32_value,
2021-06-16 18:19:05 +00:00
toDateTime('2021-04-14 11:22:33') AS date_time_value,
toDateTime64('2021-04-14 11:22:33', 3) AS date_time_64_value
2022-10-20 13:43:01 +00:00
SELECT dateName('day', date_value), dateName('day', date_32_value), dateName('day', date_time_value), dateName('day', date_time_64_value);
2021-06-16 18:19:05 +00:00
WITH
toDate('2021-04-14') AS date_value,
2022-10-20 13:43:01 +00:00
toDate32('2021-04-14') AS date_32_value,
2021-06-16 18:19:05 +00:00
toDateTime('2021-04-14 11:22:33') AS date_time_value,
toDateTime64('2021-04-14 11:22:33', 3) AS date_time_64_value
2022-10-20 13:43:01 +00:00
SELECT dateName('week', date_value), dateName('week', date_32_value), dateName('week', date_time_value), dateName('week', date_time_64_value);
2021-06-16 18:19:05 +00:00
WITH
toDate('2021-04-14') AS date_value,
2022-10-20 13:43:01 +00:00
toDate32('2021-04-14') AS date_32_value,
2021-06-16 18:19:05 +00:00
toDateTime('2021-04-14 11:22:33') AS date_time_value,
toDateTime64('2021-04-14 11:22:33', 3) AS date_time_64_value
2022-10-20 13:43:01 +00:00
SELECT dateName('weekday', date_value), dateName('weekday', date_32_value), dateName('weekday', date_time_value), dateName('weekday', date_time_64_value);
2021-06-16 18:19:05 +00:00
WITH
toDateTime('2021-04-14 11:22:33') AS date_time_value,
toDateTime64('2021-04-14 11:22:33', 3) AS date_time_64_value
SELECT dateName('hour', date_time_value), dateName('hour', date_time_64_value);
WITH
toDateTime('2021-04-14 11:22:33') AS date_time_value,
toDateTime64('2021-04-14 11:22:33', 3) AS date_time_64_value
SELECT dateName('minute', date_time_value), dateName('minute', date_time_64_value);
WITH
toDateTime('2021-04-14 11:22:33') AS date_time_value,
toDateTime64('2021-04-14 11:22:33', 3) AS date_time_64_value
SELECT dateName('second', date_time_value), dateName('second', date_time_64_value);
WITH
toDateTime('2021-04-14 23:22:33', 'UTC') as date
SELECT
dateName('weekday', date, 'UTC'),
dateName('hour', date, 'UTC'),
dateName('minute', date, 'UTC'),
dateName('second', date, 'UTC');
WITH
toDateTime('2021-04-14 23:22:33', 'UTC') as date
SELECT
2022-03-11 23:45:26 +00:00
dateName('weekday', date, 'Asia/Istanbul'),
dateName('hour', date, 'Asia/Istanbul'),
dateName('minute', date, 'Asia/Istanbul'),
dateName('second', date, 'Asia/Istanbul');