Re: Date math question

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Kevin Kempter <kevink(at)consistentstate(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Date math question
Date: 2008-11-26 22:26:06
Message-ID: 492DCCFE.1060206@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Webb Sprague 2008-11-27 01:18:40 Group by clause creating "ERROR: wrong record type supplied in RETURN NEXT" (version 8.1.11 -- grr...)
Previous Message Steve Crawford 2008-11-26 22:10:18 Re: Odd on-update inconsistency