Re: how to add 'time with time zone' data types and 'interval' data types - Mailing list pgsql-novice

From Tom Lane
Subject Re: how to add 'time with time zone' data types and 'interval' data types
Date
Msg-id 14757.1389112440@sss.pgh.pa.us
Whole thread Raw
In response to Re: how to add 'time with time zone' data types and 'interval' data types  (Kevin Grittner <kgrittn@ymail.com>)
List 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 by date:

Previous
From: Sameer Kumar
Date:
Subject: Re: Master-slave failover question
Next
From: Sergey Konoplev
Date:
Subject: Re: Master-slave failover question