Search code examples
sqlimpala

Impala SQL - How to Truncate Timestamp to Day?


Using Cloudera's Impala SQL, is there a way to truncate a timestamp by day?

i.e. go from:

2015-05-01 01:23:45 -> 2015-05-01 00:00:00
2015-05-01 12:34:56 -> 2015-05-01 00:00:00
2015-05-01 23:45:59 -> 2015-05-01 00:00:00

The default TRUNC options only seem to enable Week or Hour, not Day...


Solution

  • By my read of the tests, you should be able to pass DDD, DD, or J to TRUNC to get this behavior. I agree that the docs are not clear on this point though--I've filed an issue to get the documentation cleaned up.