Re: daterange constructor vs cast

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Shvidky Andrey <andrey_shvidky(at)hotmail(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: daterange constructor vs cast
Date: 2023-12-11 17:04:13
Message-ID: 2286798.1702314253@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Shvidky Andrey <andrey_shvidky(at)hotmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Lakhin 2023-12-12 03:00:00 Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends
Previous Message Shvidky Andrey 2023-12-11 16:14:38 daterange constructor vs cast