From: Tom Lane <tgl@sss.pgh.pa.us>
To: Chuck Martin <clmartin@theombudsman.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Query not producing expected result
Date: Wed, 01 May 2019 12:41:24 -0400
Message-ID: <25696.1556728884@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFw6=U2AisghJ2cOPOWopmk3NVVJ-WcSTNM+6K_-kQVBGxzMaA@mail.gmail.com>
References: <CAFw6=U2AisghJ2cOPOWopmk3NVVJ-WcSTNM+6K_-kQVBGxzMaA@mail.gmail.com>
Chuck Martin <clmartin@theombudsman.com> writes:
> 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".
Well, no, since the implied value of the constant is 'May-1-2019 00:00'.
If you only want 1-day precision of the comparison, maybe you should cast
or truncate the timestamp down to date.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, clmartin@theombudsman.com
Subject: Re: Query not producing expected result
In-Reply-To: <25696.1556728884@sss.pgh.pa.us>
References: <CAFw6=U2AisghJ2cOPOWopmk3NVVJ-WcSTNM+6K_-kQVBGxzMaA@mail.gmail.com> <25696.1556728884@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox