pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feeddaterange constructor vs cast
2+ messages / 2 participants
[nested] [flat]
* daterange constructor vs cast
@ 2023-12-11 16:14 Shvidky Andrey <andrey_shvidky@hotmail.com>
2023-12-11 17:04 ` Re: daterange constructor vs cast Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: Shvidky Andrey @ 2023-12-11 16:14 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Hello!
Aren't these 6 results must be the same?
select
daterange('[20231211', '20231211]')
,daterange('[20231211', '20231212)')
,daterange('20231211', '20231211', '[]')
,daterange('20231211', '20231212', '[)')
,'[20231211,20231211]'::daterange
,'[20231211,20231212)'::daterange
daterange|daterange |daterange |daterange |daterange |daterange |
---------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
empty |[2023-12-11,2023-12-12)|[2023-12-11,2023-12-12)|[2023-12-11,2023-12-12)|[2023-12-11,2023-12-12)|[2023-12-11,2023-12-12)|
Thanks in advance!
Andrey N. Shvidky.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: daterange constructor vs cast
2023-12-11 16:14 daterange constructor vs cast Shvidky Andrey <andrey_shvidky@hotmail.com>
@ 2023-12-11 17:04 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2023-12-11 17:04 UTC (permalink / raw)
To: Shvidky Andrey <andrey_shvidky@hotmail.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Shvidky Andrey <andrey_shvidky@hotmail.com> writes:
> Aren't these 6 results must be the same?
I think you have the wrong idea of how range constructors work.
This:
> daterange('[20231211', '20231211]')
> ,daterange('[20231211', '20231212)')
is not valid input really. It happens to not fail because date_in
ignores garbage punctuation; but nothing is considering those
brackets or parens as indicating range end types.
These are the approved way to do it:
> ,daterange('20231211', '20231211', '[]')
> ,daterange('20231211', '20231212', '[)')
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2023-12-11 17:04 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-12-11 16:14 daterange constructor vs cast Shvidky Andrey <andrey_shvidky@hotmail.com>
2023-12-11 17:04 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox