Is upper_inc ever true for dateranges?

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Is upper_inc ever true for dateranges?
Date: 2020-07-28 21:18:47
Message-ID: CAD3a31X-c9HpHr0B7-NWkAco-XWh_pHL6D-ixMuMgv=Xsnbz=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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
*http://agency-software.org/ <http://agency-software.org/>*
*https://demo.agency-software.org/client
<https://demo.agency-software.org/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2020-07-28 21:23:55 Re: Is upper_inc ever true for dateranges?
Previous Message Andres Freund 2020-07-28 21:07:48 Re: bad JIT decision