Re: Date Arithmetic in PL/pgSql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John DeSoi <desoi(at)pgedit(dot)com>
Cc: Lane Van Ingen <lvaningen(at)esncc(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Date Arithmetic in PL/pgSql
Date: 2005-08-08 21:09:29
Message-ID: 9237.1123535369@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

John DeSoi <desoi(at)pgedit(dot)com> writes:
> On Aug 8, 2005, at 4:23 PM, Lane Van Ingen wrote:
>> I am trying to do some simple date arithmetic.

> select '2005-08-08 16:15:30'::timestamp - '310 seconds'::interval;

I think the "computed" part is the bit that's missing. Maybe he wants

select '2005-08-08 16:15:30'::timestamp - (expression) * '1 sec'::interval;

This should work for pretty much any numeric expression.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jeff Eckermann 2005-08-08 23:48:29 Re: Uploading and loading
Previous Message John DeSoi 2005-08-08 20:45:07 Re: Date Arithmetic in PL/pgSql