ClickHouse/tests/queries/0_stateless/01269_toStartOfSecond.sql
Vasily Nemkov 2c2005817f New function toStartOfSecond(DateTime64) -> DateTime64
This funtion nullifies sub-second part of DateTime64 value.
2020-05-11 12:06:06 +03:00

13 lines
845 B
SQL

-- Error cases
SELECT toStartOfSecond('123'); -- {serverError 43}
SELECT toStartOfSecond(now()); -- {serverError 43}
SELECT toStartOfSecond(); -- {serverError 42}
SELECT toStartOfSecond(now64(), 123); -- {serverError 43}
WITH toDateTime64('2019-09-16 19:20:11', 3) AS dt64 SELECT toStartOfSecond(dt64, 'UTC') AS res, toTypeName(res);
WITH toDateTime64('2019-09-16 19:20:11', 0, 'UTC') AS dt64 SELECT toStartOfSecond(dt64) AS res, toTypeName(res);
WITH toDateTime64('2019-09-16 19:20:11.123', 3, 'UTC') AS dt64 SELECT toStartOfSecond(dt64) AS res, toTypeName(res);
WITH toDateTime64('2019-09-16 19:20:11.123', 9, 'UTC') AS dt64 SELECT toStartOfSecond(dt64) AS res, toTypeName(res);
SELECT 'non-const column';
WITH toDateTime64('2019-09-16 19:20:11.123', 3, 'UTC') AS dt64 SELECT toStartOfSecond(materialize(dt64)) AS res, toTypeName(res);