Re: Problem with CAST-ing - am I missing something?

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Problem with CAST-ing - am I missing something?
Дата
Msg-id 9bc42afd-8be3-47f3-aa7d-20bf12ca39de@aklaver.com
обсуждение исходный текст
Ответ на Re: Problem with CAST-ing - am I missing something?  (Christophe Pettus <xof@thebuild.com>)
Список pgsql-general
On 10/25/23 17:26, Christophe Pettus wrote:
> 
> 
>> On Oct 25, 2023, at 17:21, Pól Ua Laoínecháin <linehanp@tcd.ie> wrote:
>>
>> SELECT (ts, te)::TSTZRANGE FROM test;
> 
> That syntax doesn't mean what you probably think it does.  (ts, te) defines a record type with two fields.
PostgreSQLconstructs that, and then attempts to apply the cast.  There's no conversion path from that to TSTZRANGE, so
thesystem complains.  It's imaginable, I guess, that such a path could be added, but the right way to do it is what you
dohere:
 
> 
>> SELECT TSTZRANGE(ts, te) FROM test;
> 

Or do something like:

  select '[2023-10-25 14:33:00, 2023-10-25 15:56:00)'::TSTZRANGE;
                        tstzrange
-------------------------------------------------------
  ["10/25/2023 14:33:00 PDT","10/25/2023 15:56:00 PDT")

per:

https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-IO

> 
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com




В списке pgsql-general по дате отправления:

Предыдущее
От: Christophe Pettus
Дата:
Сообщение: Re: Problem with CAST-ing - am I missing something?
Следующее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: Very newbie question