ClickHouse date format

383 views
Skip to first unread message

karthi djax

unread,
Apr 1, 2022, 8:18:08 AM4/1/22
to ClickHouse
Am having a DateTime column with value as 2022-03-28 09:15:00, would like to get get result from query as start as 2022-03-28 09:00:00 and end as 2022-03-28 09:59:59. Can you help me to get it resolved.

For start found toStartOfHour, is there any option for end of hour.

Thanks in Advance

Regards,
Karthik 

Ivan Blinkov

unread,
Apr 1, 2022, 9:30:56 AM4/1/22
to karthi djax, ClickHouse
Hi Karthik,

It sounds like to calculate end you could get that start of hour, add one hour to it and then subtract one second? There are multiple ways to do it, for example there are these functions: 

--
Ivan

--
You received this message because you are subscribed to the Google Groups "ClickHouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clickhouse+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clickhouse/c2a80652-aa97-4775-9684-18c65e58e3ban%40googlegroups.com.
--
--
Ivan Blinkov

karthi djax

unread,
Apr 2, 2022, 3:10:39 AM4/2/22
to ClickHouse
Hi Ivan,

Thanks for the details, done with solution as below,

select DISTINCT date_time, addHours(date_time, 1) AS next_hour, date_sub(SECOND, 1, next_hour) AS end_time from date_check;

Thanks again

karthi djax

unread,
Apr 2, 2022, 3:12:42 AM4/2/22
to ClickHouse
Aldo this works
select DISTINCT date_time, date_sub(SECOND, 1, addHours(date_time, 1)) AS end_time from ox_data_summary_ad_hourly_cron;

Reply all
Reply to author
Forward
0 new messages