Skip site navigation (1) Skip section navigation (2)

Re: FW: Re: Part 1 of several - Converting a varchar to an interval

From: Shawn <postgres(at)xmtservices(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: FW: Re: Part 1 of several - Converting a varchar to an interval
Date: 2008-03-26 22:45:53
Message-ID: 200803262245.53968.postgres@xmtservices.net (view raw or flat)
Thread:
Lists: pgsql-sql
On Wednesday 26 March 2008 17:14:28 Tom Lane wrote:
> Or even easier:
>
> regression=# select 134987 * interval '1 msec';
>    ?column?  
> --------------
>  00:02:14.987
> (1 row)
>
>
>                         regards, tom lane

Tom and Adrian,

i am trying to incorporate the solution you gave into a function, trying to 
save some typing.  Its keeps throwing a syntax error:

edacs=# create or replace function dur_interval_msec(char) returns interval
as 'select ($1 * interval '1 msec');'
language sql
immutable
returns null on null input;
ERROR:  syntax error at or near "1"
LINE 2: as 'select ($1 * interval '1 msec');'
                                   ^
obviously it doesn't like the extra single quotes around the 1 msec.  Any 
suggestions for a work around?

Shawn

In response to

Responses

pgsql-sql by date

Next:From: Rodrigo E. De León PlicetDate: 2008-03-26 23:12:07
Subject: Re: FW: Re: Part 1 of several - Converting a varchar to an interval
Previous:From: Adrian KlaverDate: 2008-03-26 20:02:51
Subject: Re: FW: Re: Part 1 of several - Converting a varchar to an interval

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group