Re: syntax for using function parameter in to_char

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Kevin Barrett <anon000000(at)hotmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: syntax for using function parameter in to_char
Date: 2002-02-01 20:40:25
Message-ID: web-682424@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Kevin,

> CREATE FUNCTION java_date( bigint ) RETURNS text AS '
> select to_char(\'epoch\'::datetime + \'$1 seconds\'::interval,
> \'dd/mm/yyyy hh:mi\') as RESULT
> '
> LANGUAGE 'sql';

Try this instead:

CREATE FUNCTION java_date( bigint ) RETURNS text AS '
select to_char(''epoch''::datetime +
(CAST($1 AS VARCHAR) || ''seconds'')::interval,
''dd/mm/yyyy hh:mi'') as RESULT
'
LANGUAGE 'sql';

Got it? Check, though, a "CAST (bigint as varchar)" may or may not
work.

-Josh

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2002-02-01 21:19:55 Re: NOTICE: Vacuum: can not process indices, views and certain system tables
Previous Message Tom Lane 2002-02-01 20:39:52 Re: pg_vlock / vacuum