ClickHouse/tests/queries/0_stateless/01561_Date_and_DateTime64_comparision.sql
Vasily Nemkov 5ff7baf663 Fixed comparing Date and DateTime64
With a less flakky test
2020-12-18 17:47:08 +02:00

44 lines
789 B
SQL

SELECT
n,
toTypeName(dt64) AS dt64_typename,
'<',
dt64 < d,
toDate(dt64) < d,
dt64 < toDateTime64(d, 1, 'UTC'),
'<=',
dt64 <= d,
toDate(dt64) <= d,
dt64 <= toDateTime64(d, 1, 'UTC'),
'=',
dt64 = d,
toDate(dt64) = d,
dt64 = toDateTime64(d, 1, 'UTC'),
'>=',
dt64 >= d,
toDate(dt64) >= d,
dt64 >= toDateTime64(d, 1, 'UTC'),
'>',
dt64 > d,
toDate(dt64) > d,
dt64 > toDateTime64(d, 1, 'UTC'),
'!=',
dt64 != d,
toDate(dt64) != d,
dt64 != toDateTime64(d, 1, 'UTC')
FROM
(
WITH toDateTime('2019-09-16 19:20:11') as val
SELECT
number - 1 as n,
toDateTime64(val, 1, 'UTC') AS dt64,
toDate(val, 'UTC') - n as d
FROM system.numbers
LIMIT 3
)