Re: how to add 'time with time zone' data types and 'interval' data types

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: how to add 'time with time zone' data types and 'interval' data types
Дата
Msg-id 14757.1389112440@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: how to add 'time with time zone' data types and 'interval' data types  (Kevin Grittner <kgrittn@ymail.com>)
Список pgsql-novice
Kevin Grittner <kgrittn@ymail.com> writes:
> avpro avpro <avprowebeden@gmail.com> wrote:
>> select '12:00'::time - '9:00'::time; didn't work.

> I get this on 9.3:

> test=# select '12:00'::time - '9:00'::time;
> �?column?
> ----------
> �03:00:00

Note that that yields an interval, not a time.  I think the OP may
be unhappy about the type mismatch.  He could just add a cast,
though.  In the addition case, casting one or both of the times to
interval might do what he wants, too, depending on whether he's
looking for wraparound behavior:

regression=# select '12:00'::time + '19:00'::time::interval;
 ?column?
----------
 07:00:00
(1 row)

regression=# select '12:00'::time::interval + '19:00'::time::interval;
 ?column?
----------
 31:00:00
(1 row)

            regards, tom lane


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

Предыдущее
От: Sameer Kumar
Дата:
Сообщение: Re: Master-slave failover question
Следующее
От: Sergey Konoplev
Дата:
Сообщение: Re: Master-slave failover question