Re: Strange behavior between timestamp and date comparison - Mailing list pgsql-general

From Rory Campbell-Lange
Subject Re: Strange behavior between timestamp and date comparison
Date
Msg-id Yt1lcRA2X2uwUk3H@campbell-lange.net
Whole thread Raw
In response to Strange behavior between timestamp and date comparison  (Ludwig Isaac Lim <ludz_lim@yahoo.com>)
List pgsql-general
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




pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Queries in another user's tables
Next
From: Adrian Klaver
Date:
Subject: Re: Strange behavior between timestamp and date comparison