mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
f9cd6a09e6
* start * wip * wip * wip * wip * wip * Fix clickhouse-server.postinst * clean * wip * clean * clean * clean * wip * clean * Update dump_variable.cpp
40 lines
2.0 KiB
SQL
40 lines
2.0 KiB
SQL
|
|
SELECT EXTRACT(DAY FROM toDate('2017-06-15'));
|
|
SELECT EXTRACT (MONTH FROM toDate('2017-06-15'));
|
|
SELECT EXTRACT(YEAR FROM toDate('2017-06-15'));
|
|
SELECT EXTRACT(SECOND FROM toDateTime('2017-12-31 18:59:58'));
|
|
SELECT EXTRACT(MINUTE FROM toDateTime('2017-12-31 18:59:58'));
|
|
SELECT EXTRACT(HOUR FROM toDateTime('2017-12-31 18:59:58'));
|
|
SELECT EXTRACT(DAY from toDateTime('2017-12-31 18:59:58'));
|
|
SELECT extract(MONTH FROM toDateTime('2017-12-31 18:59:58'));
|
|
SELECT EXTRACT(year FROM toDateTime('2017-12-31 18:59:58'));
|
|
|
|
|
|
DROP TABLE IF EXISTS test.Orders;
|
|
CREATE TABLE test.Orders (OrderId UInt64, OrderName String, OrderDate DateTime) engine = Log;
|
|
insert into test.Orders values (1, 'Jarlsberg Cheese', toDateTime('2008-10-11 13:23:44'));
|
|
SELECT EXTRACT(YEAR FROM OrderDate) AS OrderYear, EXTRACT(MONTH FROM OrderDate) AS OrderMonth, EXTRACT(DAY FROM OrderDate) AS OrderDay,
|
|
EXTRACT(HOUR FROM OrderDate), EXTRACT(MINUTE FROM OrderDate), EXTRACT(SECOND FROM OrderDate) FROM test.Orders WHERE OrderId=1;
|
|
DROP TABLE test.Orders;
|
|
|
|
|
|
-- TODO:
|
|
-- SELECT EXTRACT(WEEK FROM toDate('2017-06-15'));
|
|
-- SELECT EXTRACT(WEEK FROM toDateTime('2017-12-31 18:59:58'));
|
|
-- SELECT EXTRACT(MINUTE_SECOND FROM toDateTime('2017-12-31 18:59:58'));
|
|
-- SELECT EXTRACT(HOUR_SECOND FROM toDateTime('2017-12-31 18:59:58'));
|
|
-- SELECT EXTRACT(HOUR_MINUTE FROM toDateTime('2017-12-31 18:59:58'));
|
|
-- SELECT EXTRACT(DAY_SECOND FROM toDateTime('2017-12-31 18:59:58'));
|
|
-- SELECT EXTRACT(DAY_MINUTE FROM toDateTime('2017-12-31 18:59:58'));
|
|
-- SELECT EXTRACT(DAY_HOUR FROM toDateTime('2017-12-31 18:59:58'));
|
|
-- SELECT EXTRACT(YEAR_MONTH FROM toDateTime('2017-12-31 18:59:58'));
|
|
-- SELECT EXTRACT(QUARTER FROM toDate('2017-06-15'));
|
|
-- SELECT EXTRACT(DAY_SECOND FROM toDate('2017-06-15'));
|
|
-- SELECT EXTRACT(DAY_MINUTE FROM toDate('2017-06-15'));
|
|
-- SELECT EXTRACT(DAY_HOUR FROM toDate('2017-06-15'));
|
|
-- SELECT EXTRACT(YEAR_MONTH FROM toDate('2017-06-15'));
|
|
-- SELECT EXTRACT(QUARTER FROM toDateTime('2017-12-31 18:59:58'));
|
|
|
|
-- Maybe:
|
|
-- SELECT EXTRACT (YEAR FROM DATE '2014-08-22') AS RESULT;
|