Re: Question on interval

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Wei Weng <wweng(at)kencast(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Question on interval
Date: 2007-04-20 20:11:06
Message-ID: 1177099866.24411.30.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, 2007-04-20 at 13:53, Wei Weng wrote:
> Hi all.
>
> How do I write a query that converts an interger to the interval type?
>
> Like convert integer 10 to INTERVAL '10 seconds'?
>
> The integer is a column in a table though, so it is more like convert
> integer tbl.theInteger to INTERVAL 'tbl.theInteger seconds".

A lot of the times, it's easiest to multiply it:

select ..... where somedatefield > now() - interval '1 minute' * 5

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Crawford 2007-04-21 00:38:54 Re: Question on interval
Previous Message Michael Glaesemann 2007-04-20 19:35:29 Re: Question on interval