Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g11Kegl41108 for ; Fri, 1 Feb 2002 15:40:43 -0500 (EST) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.2) with HTTP id 682424; Fri, 01 Feb 2002 12:40:25 -0800 From: "Josh Berkus" Subject: Re: syntax for using function parameter in to_char To: Kevin Barrett , pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.2 Date: Fri, 01 Feb 2002 12:40:25 -0800 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200202/29 X-Sequence-Number: 6461 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@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco