Date math question

Started by Kevin Kempterover 17 years ago2 messagesgeneral
Jump to latest
#1Kevin Kempter
kevink@consistentstate.com

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

#2Steve Crawford
scrawford@pinpointresearch.com
In reply to: Kevin Kempter (#1)
Re: Date math question

Kevin Kempter wrote:

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 ?

Try

ts + dursec * '1 second'::interval

Cheers,
Steve