Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFdYR-0001Kv-Oq for pgsql-general@arkaria.postgresql.org; Sun, 24 Jul 2022 15:30:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oFdYQ-0007eJ-FQ for pgsql-general@arkaria.postgresql.org; Sun, 24 Jul 2022 15:30:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFdYP-0007du-RS for pgsql-general@lists.postgresql.org; Sun, 24 Jul 2022 15:30:02 +0000 Received: from campbell-lange.net ([178.79.140.51]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFdYK-0001dN-HR for pgsql-general@postgresql.org; Sun, 24 Jul 2022 15:30:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=campbell-lange.net; s=it; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=y1/a3uI+1rK6j0ABF3aPslxoEjyxBtIyTCLAg/g3ylE=; b=HS9qQdQ7ddOL8Zz5rxXIy6570w 1OuNPGmwvpniukcDyJ/VrPXHHnlg8EG9cvXC40JfLb68IUinuTsXXK+zzVD97z7UNuPDsAuQZZb+g Ug46a/nGb1mR0BksCFcwn2Cg4EOXMEXDLpCuqvIsaWfisNBtLrbB39cKipSKT3vo8rFA=; Received: from 232.178.125.91.dyn.plus.net ([91.125.178.232] helo=rory-t470s) by campbell-lange.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oFdYI-006JE0-7Q; Sun, 24 Jul 2022 15:29:54 +0000 Received: from rory by rory-t470s with local (Exim 4.94.2) (envelope-from ) id 1oFdYH-003Y8b-LV; Sun, 24 Jul 2022 16:29:53 +0100 Date: Sun, 24 Jul 2022 16:29:53 +0100 From: Rory Campbell-Lange To: Ludwig Isaac Lim Cc: "pgsql-general@postgresql.org" Subject: Re: Strange behavior between timestamp and date comparison Message-ID: References: <1485906141.916850.1658570664512.ref@mail.yahoo.com> <1485906141.916850.1658570664512@mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1485906141.916850.1658570664512@mail.yahoo.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 23/07/22, Ludwig Isaac Lim (ludz_lim@yahoo.com) wrote: > Below is a sample case that exhibits a behavior that I can't explain: > > -- create the table > create table ts (t timestamp without time zone); > > -- populate > insert into ts(t) values ('2022-07-16 00:22:06.974000'); > insert into ts(t) values ('2022-07-16 00:22:06.974000'); > insert into ts(t) values ('2022-07-16 00:22:06.974000'); > -- This one doesn't return anything (unexpected) >  select * from ts where t between '2022-07-16'::Date - make_interval(days => 30) and '2022-07-16'::Date; It looks like all of your timestamps are outside of the upper bound of "between". template1=> select ('2022-07-16'::Date)::timestamp; timestamp --------------------- 2022-07-16 00:00:00