From: Rory Campbell-Lange <rory@campbell-lange.net>
To: Ludwig Isaac Lim <ludz_lim@yahoo.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Strange behavior between timestamp and date comparison
Date: Sun, 24 Jul 2022 16:29:53 +0100
Message-ID: <Yt1lcRA2X2uwUk3H@campbell-lange.net> (raw)
In-Reply-To: <1485906141.916850.1658570664512@mail.yahoo.com>
References: <1485906141.916850.1658570664512.ref@mail.yahoo.com>
<1485906141.916850.1658570664512@mail.yahoo.com>
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
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: rory@campbell-lange.net, ludz_lim@yahoo.com
Subject: Re: Strange behavior between timestamp and date comparison
In-Reply-To: <Yt1lcRA2X2uwUk3H@campbell-lange.net>
References: <1485906141.916850.1658570664512.ref@mail.yahoo.com> <1485906141.916850.1658570664512@mail.yahoo.com> <Yt1lcRA2X2uwUk3H@campbell-lange.net>
* 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