How to filter ELB logs by today's date? I've tried this query:

SELECT request_timestamp
FROM elb_logs
WHERE date_trunc('day', request_timestamp) = date_trunc('day', current_timestamp)
LIMIT 10


but it fails with:


  SYNTAX_ERROR: line 3:7: Unexpected parameters (varchar(3), varchar) for function date_trunc. Expected: date_trunc(varchar(x), date) , date_trunc(varchar(x), time) , date_trunc(varchar(x), time with time zone) , date_trunc(varchar(x), timestamp) , date_trunc(varchar(x), timestamp with time zone)


I've checked the Date and Time Functions and Operators docs page, but I can't see anything wrong.

I've created the elb_logs table in Amazon Athena according to this page.

What I am missing?
Either request_timestamp needs to be converted from the ISO 8601 formatted string into a timestamp with time zone, or current_timestamp needs to be converted into the string.

One method is to convert request_timestamp into a string in format %Y-%m-%d, e.g.


split_part(request_timestamp, 'T', 1)
substr(request_timestamp, 1, 10)


then compare it with current_timestamp which can be converted to the ISO 8601 formatted string.

Here is the final query:

SELECT *
FROM elb_logs
WHERE split_part(request_timestamp, 'T', 1) = split_part(to_iso8601(current_timestamp), 'T', 1)
LIMIT 10