mysql
在'2023-10-27 23:59:59'上增加5秒:
sql
SELECT DATE_ADD('2023-10-27 23:59:59', INTERVAL 5 second);
clickhouse
sql
SELECT date_add(SECOND, 3, toDate('2018-01-01 00:00:00'));
clickhouse时间按秒、分、时、日、月、年作差
按秒:
sql
SELECT dateDiff('second', toDateTime('2022-01-01 20:00:00'), toDateTime('2022-01-02 23:00:00'));
结果 = toDateTime('2022-01-02 23:00:00') - toDateTime('2022-01-01 20:00:00')
![在这里插入图片描述](https://img-blog.csdnimg.cn/7873b1505c894c85925deff0a940cdc6.png
按时:
sql
SELECT dateDiff('hour', toDateTime('2022-01-01 20:00:00'), toDateTime('2022-01-02 23:00:00'));