Search code examples
mysqlclickhouse

Last Nth Day in click house


I use above condition in mysql to extract last 7 day date. how it works in clickhouse ?? I tried looking for it in click house docs but found nothing

   where date(created_at) = CURDATE() - INTERVAL 7 DAY

Solution

  • As the documentation shows, Clickhouse supports interval syntax (similar to other databases such as MySQL and Postgres).

    We can rewrite your MySQL WHERE clause in Clickhouse as follows:

    WHERE toDate(created_at) = toDate(now()) - INTERVAL 7 DAY