Skip site navigation (1) Skip section navigation (2)

Re: adding times togeather

From: Alvaro Herrera Munoz <alvherre(at)dcc(dot)uchile(dot)cl>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
Cc: ed despard <despareg(at)clarkson(dot)edu>, pgsql-general(at)postgresql(dot)org
Subject: Re: adding times togeather
Date: 2003-04-28 23:26:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Mon, Apr 28, 2003 at 02:25:54PM -0800, Steve Crawford wrote:

> You can:
> Subtract two times and get an interval
> Add an interval to a time to get a time

Beware:  you cannot (in 7.2.3 at least -- I don't have 7.3 available for
testing) add a timestamp to an interval and expect a reasonable value.
You have to add the interval to the timestamp.

h=> select '05:04:03'::interval + '2003-mar-01 09:05:00'::timestamp;
 2003-03-01 05:04:03
(1 row)

h=> select '2003-mar-01 09:05:00'::timestamp + '05:04:03'::interval;
 2003-03-01 14:09:03-03
(1 row)

h=> select version();
 PostgreSQL 7.2.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
(1 row)

In response to


pgsql-general by date

Next:From: Benjamin ScherreyDate: 2003-04-28 23:32:24
Subject: Bug(?) with cursors using aggregate functions.
Previous:From: Steve CrawfordDate: 2003-04-28 23:11:34
Subject: Re: adding times togeather

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group