Обсуждение: Is upper_inc ever true for dateranges?

Поиск
Список
Период
Сортировка

Is upper_inc ever true for dateranges?

От
Ken Tanzer
Дата:
Hi.  Regardless of how I specify a daterange, it is converted to inclusive lower bound, exclusive upper bound ('[)'):

SELECT daterange('2019-01-01','2020-01-01','(]') AS range;
          range          
-------------------------
 [2019-01-02,2020-01-02)

So here's my question.  Will the upper_inc function always return false for a non-null daterange?  And if so, what's the point of the function?  And/or is it different for other kinds of ranges?

lower_inc at least seems to return true if lower bound is not null, but false if it is null.


WITH r AS (SELECT daterange('2020-01-01','2020-01-31','(]') AS range) SELECT range,upper_inc(range),lower_inc(range) FROM r;

          range          | upper_inc | lower_inc
-------------------------+-----------+-----------
 [2020-01-02,2020-02-01) | f         | t

     range     | upper_inc | lower_inc
---------------+-----------+-----------
 [2020-01-02,) | f         | t

     range     | upper_inc | lower_inc
---------------+-----------+-----------
 (,2020-01-02) | f         | f

Thanks in advance!

Ken



--
AGENCY Software  
A Free Software data system
By and for non-profits
(253) 245-3801

learn more about AGENCY or
follow the discussion.

Re: Is upper_inc ever true for dateranges?

От
"David G. Johnston"
Дата:
On Tue, Jul 28, 2020 at 2:19 PM Ken Tanzer <ken.tanzer@gmail.com> wrote:
So here's my question.  Will the upper_inc function always return false for a non-null daterange?  And if so, what's the point of the function?  And/or is it different for other kinds of ranges?

Ranges over discrete types are always canonicalized while ranges over non-discrete types (i.e., float) cannot.

David J.


Re: Is upper_inc ever true for dateranges?

От
Ken Tanzer
Дата:
On Tue, Jul 28, 2020 at 2:24 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tue, Jul 28, 2020 at 2:19 PM Ken Tanzer <ken.tanzer@gmail.com> wrote:
So here's my question.  Will the upper_inc function always return false for a non-null daterange?  And if so, what's the point of the function?  And/or is it different for other kinds of ranges?

Ranges over discrete types are always canonicalized while ranges over non-discrete types (i.e., float) cannot.


Oh that makes perfect sense.  Thank you!

Ken

 
David J.




--
AGENCY Software  
A Free Software data system
By and for non-profits
(253) 245-3801

learn more about AGENCY or
follow the discussion.