Re: range type expression syntax

Поиск
Список
Период
Сортировка
От John Turner
Тема Re: range type expression syntax
Дата
Msg-id op.xuolbodlk4admm@eis158.energi.com
обсуждение исходный текст
Ответ на range type expression syntax  (John Turner <jjturner@energi.com>)
Ответы Re: range type expression syntax  (Marc Mamin <M.Mamin@intershop.de>)
Список pgsql-general
On Thu, 26 Feb 2015 15:11:28 -0500, John Turner <jjturner@energi.com>
wrote:

> Seems I'm missing a trick trying to get rangetypes working:
>
> No problem building the string:
> select concat('''[', now()::date, ',', now()::date, ']''') testrange;
>            testrange
> ---------------------------
>   '[2015-02-26,2015-02-26]'
> (1 row)
>
> Bombed-out trying to turn this into a daterange:
> postgres=# select concat('''[', now()::date, ',', now()::date,
> ']''')::daterange testrange;
> ERROR:  malformed range literal: "'[2015-02-26,2015-02-26]'"
> DETAIL:  Missing left parenthesis or bracket.
>
> Is there a specific casting I need to apply in order to render a literal
> daterange from parameterized range elements?
>
> /john
>
>
Sorry - too quick to post, I realize there was no need to wrap the
expression in extra quotes:

postgres=# select concat('[', now()::date, ',', now()::date,
']')::daterange testrange;
         testrange
-------------------------
  [2015-02-26,2015-02-27)
(1 row)


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

Предыдущее
От: John Turner
Дата:
Сообщение: range type expression syntax
Следующее
От: Tong Michael
Дата:
Сообщение: how to do merge in postgres ("with upsert as" not supported)