Re: daterange() is ignoring 3rd boundaries argument - Mailing list pgsql-bugs

From Tom Lane
Subject Re: daterange() is ignoring 3rd boundaries argument
Date
Msg-id 778131.1669682544@sss.pgh.pa.us
Whole thread Raw
In response to daterange() is ignoring 3rd boundaries argument  (Robert KOFLER <rk@marksim.org>)
List pgsql-bugs
Robert KOFLER <rk@marksim.org> writes:
> select daterange('2022-11-01'::date, '2023-01-31'::date, '()')
> returns
> [2022-11-02,2023-01-31) which is deafult of [)
> instead of
> (2022-11-02,2023-01-31)

It's not "ignoring" the endpoint argument, because you get different
results from

regression=# select daterange('2022-11-01'::date, '2023-01-31'::date, '()');
        daterange        
-------------------------
 [2022-11-02,2023-01-31)
(1 row)

regression=# select daterange('2022-11-01'::date, '2023-01-31'::date, '[)');
        daterange        
-------------------------
 [2022-11-01,2023-01-31)
(1 row)

regression=# select daterange('2022-11-01'::date, '2023-01-31'::date, '[]');
        daterange        
-------------------------
 [2022-11-01,2023-02-01)
(1 row)

As explained somewhere in the fine manual (though not in the exact spot
you're reading), for ranges over discrete types such as dates, we prefer
to normalize to the '[)' endpoint conventions.  That's not possible for
continuous types such as floats or timestamps, so in those cases we
leave the endpoint specs alone.

If that really annoys you, you can make your own range type over
dates that lacks a "canonical" function.  But it's not a bug;
it's operating as intended.

            regards, tom lane



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: daterange() is ignoring 3rd boundaries argument
Next
From: Richard Guo
Date:
Subject: Re: BUG #17700: An assert failed in prepjointree.c