pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shawn <postgres@xmtservices.net>
To: pgsql-sql@postgresql.org
Subject: Re: FW: Re: Part 1 of several - Converting a varchar to an interval
Date: Wed, 26 Mar 2008 22:45:53 +0000
Message-ID: <200803262245.53968.postgres@xmtservices.net> (raw)
In-Reply-To: <29426.1206551668@sss.pgh.pa.us>
References: <032620081632.25756.47EA7AA200070FAB0000649C22007374789D0A900E04050E@comcast.net>
	<29426.1206551668@sss.pgh.pa.us>

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



view thread (11+ messages)  latest in thread

Message-ID: <200803262245.53968.postgres@xmtservices.net>
Permalink:  ../200803262245.53968.postgres@xmtservices.net/
Also on:    postgresql.org/message-id/200803262245.53968.postgres@xmtservices.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: postgres@xmtservices.net
  Subject: Re: FW: Re: Part 1 of several - Converting a varchar to an interval
  In-Reply-To: <200803262245.53968.postgres@xmtservices.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox