I have a table with a field called recordTime
of type timestamp without time zone
. I want to select today's rows only (i.e. since midnight). The records are sourced globally and arrive as UTC, so I need to select rows based on midnight UTC.
There seems to be a myriad of ways of doing this including ...
WHERE date_trunc('day', recordTime) = current_date ;WHERE date_trunc('day', recordTime) = date_trunc('day', current_date at time zone 'utc') WHERE date_trunc('day', recordTime) = date_trunc('day', current_timestamp at time zone 'utc') WHERE recordTime >= '17-May-2024 00:00:00'
Which of these is best practice - or maybe a different method entirely? (Bearing in mind that performance seems similar in all cases.)