From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
Cc: | avpro avpro <avprowebeden(at)gmail(dot)com>, "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: how to add 'time with time zone' data types and 'interval' data types |
Date: | 2014-01-07 16:34:00 |
Message-ID: | 14757.1389112440@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Kevin Grittner <kgrittn(at)ymail(dot)com> writes:
> avpro avpro <avprowebeden(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Sergey Konoplev | 2014-01-07 17:55:19 | Re: Master-slave failover question |
Previous Message | Kevin Grittner | 2014-01-07 16:16:41 | Re: how to add 'time with time zone' data types and 'interval' data types |