Re: Query not producing expected result
От | David G. Johnston |
---|---|
Тема | Re: Query not producing expected result |
Дата | |
Msg-id | CAKFQuwYH8-zkGPOPrE9zRQ_z_PPjS5db8i6Vw9iX_BLYaJn7vQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Query not producing expected result (Chuck Martin <clmartin@theombudsman.com>) |
Список | pgsql-general |
On Wed, May 1, 2019 at 9:27 AM Chuck Martin <clmartin@theombudsman.com> wrote:
I need help figuring out why a query is not returning the records I expect it to. I'm searching on a DateTime column (timestamp without time zone - not nullable). The query includes:AND event.Primaryresp_fkey = 5000011 AND event.DateTime <= 'May-1-2019' AND event.EventDone < 1This does not return a record that has a DateTime value "May 1, 2019 9:52 AM". If I modify the query to:AND event.Primaryresp_fkey = 5000011 AND event.DateTime <= 'May-2-2019' AND event.EventDone < 1it does return the record in question. I assume I am not doing the data comparison correctly, but don't know why.
The field is a timestamp - which means there is a time involved. If you don't specify one explicitly that time is going to be midnight. 9:52AM on the 1st is after midnight on the 1st so the first query doesn't return the 9:52AM record.
IOW, the DateTime field remains as-is and the comparator is turned into a timestamp without time zone.
David J.
В списке pgsql-general по дате отправления: