Search Postgresql Archives

Re: Query not producing expected result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 1, 2019 at 9:27 AM Chuck Martin <clmartin@xxxxxxxxxxxxxxxx> 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 < 1

This 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 < 1

it 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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux