Re: Question on interval

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Rodrigo De León <rdeleonp(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org, Wei Weng <wweng(at)kencast(dot)com>
Subject: Re: Question on interval
Date: 2007-04-21 00:38:54
Message-ID: 46295D1E.6070809@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Rodrigo De León wrote:
> On 4/20/07, Wei Weng <wweng(at)kencast(dot)com> 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".
>>
>> Thanks!
>>
>>
>> Wei
>
> select (10||' sec')::interval;

Or, if you prefer:
select 10*'1 second'::interval;

Cheers,
Steve

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Lew 2007-04-21 05:20:46 Re: Floating point type to store numbers
Previous Message Scott Marlowe 2007-04-20 20:11:06 Re: Question on interval