Cherry
Cherry

Reputation: 33600

How call date_trunc function in amazon Athena?

I am trying to select the date_trunc value:

select date_trunc(HOUR, current_date - interval '1' hour);

OR

select date_trunc(HOUR, current_date);

And got error:

[42703] ERROR: column "hour" does not exist Позиция: 19

Upvotes: 11

Views: 30139

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521914

Your question borders on just being a typo, but from what I could find the date/time unit first parameter to date_trunc needs to be in single quotes:

select date_trunc('HOUR', current_date - interval '1' hour);
OR
select date_trunc('HOUR', current_date);

This answer might be worth posting as Presto's own documentation does not give any actual examples of how to use date_trunc.

Upvotes: 17

Related Questions