Thread: Adding variable intervals to timestamps

Adding variable intervals to timestamps

From
"Walker, Jed S"
Date:

Hi,

We need to add an interval (from a row in a table) to the curren time. Basically,

Table1 has the column offset_in_secs that is an integer.

Select current_timestamp + '<offset_in_secs> seconds' from table1;

But can't figure out how to do this.

-Jed

Re: Adding variable intervals to timestamps

From
Bruno Wolff III
Date:
On Mon, Aug 15, 2005 at 14:27:04 -0600,
  "Walker, Jed S" <Jed_Walker@cable.comcast.com> wrote:
> Hi,
>
> We need to add an interval (from a row in a table) to the curren time.
> Basically,
>
> Table1 has the column offset_in_secs that is an integer.
>
> Select current_timestamp + '<offset_in_secs> seconds' from table1;
>
> But can't figure out how to do this.

Select current_timestamp + offset_in_secs * '1 seconds' from table1;

Re: Adding variable intervals to timestamps

From
"Walker, Jed S"
Date:
It is amazing how sometimes you can get so pigeon-holed by the docs that
you don't see the obvious.

Thank you very much!

- Jed

-----Original Message-----
From: Bruno Wolff III [mailto:bruno@wolff.to]
Sent: Monday, August 15, 2005 2:44 PM
To: Walker, Jed S
Cc: pgsql-novice@postgresql.org
Subject: Re: Adding variable intervals to timestamps

On Mon, Aug 15, 2005 at 14:27:04 -0600,
  "Walker, Jed S" <Jed_Walker@cable.comcast.com> wrote:
> Hi,
>
> We need to add an interval (from a row in a table) to the curren time.
> Basically,
>
> Table1 has the column offset_in_secs that is an integer.
>
> Select current_timestamp + '<offset_in_secs> seconds' from table1;
>
> But can't figure out how to do this.

Select current_timestamp + offset_in_secs * '1 seconds' from table1;