Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Athena - Converting Timestamp to Date?

Looking at the Date/Time Athena documentation, I don't see a function to do this, which surprises me. The closest I see is date_trunc('week', timestamp) but that results in something like 2017-07-09 00:00:00.000 while I would like the format to be 2017-07-09

Is there an easy function to convert a timestamp to a date?

like image 995
Louis Avatar asked Jul 11 '18 18:07

Louis


People also ask

How do you change timestamp in Athena?

Athena requires the Java TIMESTAMP format. Use Presto's date and time function or casting to convert the STRING to TIMESTAMP in the query filter condition. For more information, see Date and time functions and operators in the Presto documentation.

How do you write the date in Athena?

date – A date in ISO format, such as YYYY - MM - DD . For example, date '2008-09-15' . An exception is the OpenCSVSerDe, which uses the number of days elapsed since January 1, 1970.


1 Answers

The reason for not having a conversion function is, that this can be achieved with a type cast.

So a converting query would look like this:

select DATE(current_timestamp)
like image 85
jens walter Avatar answered Sep 30 '22 18:09

jens walter