| From: | Rory Campbell-Lange <rory(at)campbell-lange(dot)net> |
|---|---|
| To: | Ludwig Isaac Lim <ludz_lim(at)yahoo(dot)com> |
| Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Strange behavior between timestamp and date comparison |
| Date: | 2022-07-24 15:29:53 |
| Message-ID: | Yt1lcRA2X2uwUk3H@campbell-lange.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 23/07/22, Ludwig Isaac Lim (ludz_lim(at)yahoo(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrian Klaver | 2022-07-24 15:33:44 | Re: Strange behavior between timestamp and date comparison |
| Previous Message | Pavel Stehule | 2022-07-24 09:19:10 | Re: Queries in another user's tables |