2

:)

I'm running queries on AWS Athena and want to check whether a certain datetime (Year-Month-Day Hour-Minute-Second) is within the current date's 00:00:00 - 23:59:59 time interval. I checked presto's documentation, but can not figure out how to pull that off in presto.

Does anyone have an idea on how this could be achieved?

Thank you!

Robey
  • 53
  • 1
  • 8
  • https://stackoverflow.com/questions/51292219/amazon-athena-converting-timestamp-to-date – shawnt00 Apr 09 '21 at 15:08
  • _"the current date's 00:00:00 - 23:59:59 time interval"_? You mean, today? – Nicholas Hunter Apr 09 '21 at 15:09
  • @NicholasHunter Yes. How can I dynamically check whether a datetime is between two different days (or on the same day) where the first day has Hour-Minute-Second set to 00:00:00 and the other day set to 23:59:59 – Robey Apr 09 '21 at 15:40
  • 1
    Have you tried WHERE DATE([AWS Time stamp]) = DATE([Comparison Date])? – Nicholas Hunter Apr 09 '21 at 15:49

1 Answers1

1

you can do

select mydate >= date_trunc('day', current_timestamp) and mydate < date_trunc('day', current_timestamp+interval '1' day)

see the date_trunc docs: https://prestodb.io/docs/current/functions/datetime.html

Nicolas Busca
  • 1,100
  • 7
  • 14