Reputation: 119
I am writing a sql query in AWS Athena, where I have a timestamp field and I had to extract the dates of June 2021 (only dates, without time).
I am able to convert timestamp to date but then having trouble with converting to varchar
.
Can anybody help please. Thanks in advance.
select substr(CAST(server_time AS VARCHAR)) from matomo_log_link_visit_action where server_time like "2021-06-%" ;
Upvotes: 2
Views: 4226
Reputation: 1305
You can use the format_datetime
function. For example:
select format_datetime(my_timestamp, 'yyyy-MM-dd')
see the docs: https://prestodb.io/docs/current/functions/datetime.html
Upvotes: 1