D] [mailto:[EMAIL PROTECTED] On Behalf Of Owen Jacobson
Sent: Tuesday, March 21, 2006 4:58 PM
To: pgsql-sql@postgresql.org
Subject: Re: [SQL] Using a parameter in Interval
Here's one I used to convert an int to an interval in another project:
CREATE OR REPLACE FUNCTION to_interval (sec INTEGER) R
On Tue, 21 Mar 2006, Davidson, Robert wrote:
> No matter how I try to concatenate, I can't seem to get a parameter to be
> used by INTERVAL in a function:
>
> CREATE OR REPLACE FUNCTION Testing(TrailingWeeks int) RETURNS date AS $$
> BEGIN
> RETURN current_date - INTERVAL (CAST(TrailingWeek
pgsql-sql@postgresql.org
Subject: [SQL] Using a parameter in Interval
No matter how I try to concatenate, I can't seem to get a parameter to be used
by INTERVAL in a function:
CREATE OR REPLACE FUNCTION Testing(TrailingWeeks int) RETURNS date AS $$
BEGIN
RETURN current_date - IN
On Mar 22, 2006, at 9:52 , Davidson, Robert wrote:
ERROR: syntax error at or near "CAST" at character 34
QUERY: SELECT current_date - INTERVAL (CAST( $1 AS varchar) || '
weeks')
CONTEXT: SQL statement in PL/PgSQL function "testing" near line 2
The generally recommended way is somethi
Title: Using a parameter in Interval
No matter how I try to concatenate, I can’t seem to get a parameter to be used by INTERVAL in a function:
CREATE OR REPLACE FUNCTION Testing(TrailingWeeks int) RETURNS date AS $$
BEGIN
RETURN current_date - INTERVAL (CAST(TrailingWeeks AS varcha