27

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?

Piotr Findeisen
  • 19,480
  • 2
  • 52
  • 82
Louis
  • 1,123
  • 5
  • 15
  • 24

2 Answers2

32

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)
jens walter
  • 13,269
  • 2
  • 56
  • 54
2

In case you have an ISO DateTime format you can use the following syntax:

select date(from_iso8601_timestamp(COLUMN_NAME)) FROM "TABLE_NAME";
Mitko Keckaroski
  • 954
  • 1
  • 8
  • 12