I am creating a view for a certain table, where rows have timestamp
fields (planned_ts
). The view needs to be sorted according to these timestamps, but since the application is only interested by the date and not the time, the result look sometimes random, especially when sorting over multiple fields.
The question I have is, if I have this query (for example) :
SELECT *
FROM tblFoo
WHERE ...
ORDER BY planned_ts ASC NULLS LAST, priority ASC
(NOTE: where priority
is an integer
field, lower means more higher priority.)
How can I change the order clause, so it does not consider the time, as if every timestamps were at 00:00:00.000
? I am aware that I can use functions in the sort clause, but I’m not sure how to do this in PostgreSQL.