Обсуждение: Date math question

Поиск
Список
Период
Сортировка

Date math question

От
Kevin Kempter
Дата:
Hi All;

I have a table that contains 2 columns ts (a timestamp) and dursec (a float -
number of seconds)

I want to insert the following into another table:

the ts (timestamp column) and a second date which is ts + dursec

I tried these select variations with no luck:

select ts, ts + interval dursec seconds from tmp2 limit 1;

select ts, ts + 'seconds' dursec from tmp2 limit 1;



Anyone know the correct syntax for this ?


Thanks in advance

Re: Date math question

От
hubert depesz lubaczewski
Дата:
On Wed, Nov 26, 2008 at 11:54:33AM -0700, Kevin Kempter wrote:
> select ts, ts + interval dursec seconds from tmp2 limit 1;
> select ts, ts + 'seconds' dursec from tmp2 limit 1;

select ts, ts + dursec * '1 second'::interval ...

depesz

--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

Re: Date math question

От
Raymond O'Donnell
Дата:
On 26/11/2008 18:54, Kevin Kempter wrote:

> I have a table that contains 2 columns ts (a timestamp) and dursec (a float -
> number of seconds)
>
> I want to insert the following into another table:
>
> the ts (timestamp column) and a second date which is ts + dursec

Something like this? -

select ts, ts + (dursec * interval '1 second')....

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------