Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hLsIT-0002Cx-B3 for pgsql-general@arkaria.postgresql.org; Wed, 01 May 2019 16:41:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hLsIS-0003I3-5l for pgsql-general@arkaria.postgresql.org; Wed, 01 May 2019 16:41:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hLsIR-0003FI-Os for pgsql-general@lists.postgresql.org; Wed, 01 May 2019 16:41:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hLsIP-0002CB-Ds for pgsql-general@postgresql.org; Wed, 01 May 2019 16:41:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x41GfOf4025697; Wed, 1 May 2019 12:41:24 -0400 From: Tom Lane To: Chuck Martin cc: pgsql-general Subject: Re: Query not producing expected result In-reply-to: References: Comments: In-reply-to Chuck Martin message dated "Wed, 01 May 2019 12:26:47 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25695.1556728884.1@sss.pgh.pa.us> Date: Wed, 01 May 2019 12:41:24 -0400 Message-ID: <25696.1556728884@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Chuck Martin 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