From: | Alban Hertroys <alban(at)magproductions(dot)nl> |
---|---|
To: | Andrus <kobruleht2(at)hot(dot)ee> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to implement GOMONTH function |
Date: | 2007-05-15 08:10:03 |
Message-ID: | 46496ADB.1080900@magproductions.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Andrus wrote:
> I need to create function GOMONTH which returns date by given number of
> month before or forward using sql or pgsql in 8.1+
> For example,
> GOMONTH( DATE '20070513', 1 ) should return date '20070613'
> GOMONTH( DATE '20070513', -2 ) should return date '20070313'
>
> I tried
>
> CREATE OR REPLACE FUNCTION public.gomonth(date, integer,
> out date) IMMUTABLE AS
> $_$
> SELECT $1 + $2'months';
This should read:
$3 := $1 + $2 * INTERVAL '1 month';
I'm not entirely sure about $3, I've never used out parameters before.
> $_$ language sql
>
> but got error
>
> ERROR: syntax error at or near "'months'"
>
> How to implement this ?
>
> Andrus.
--
Alban Hertroys
alban(at)magproductions(dot)nl
magproductions b.v.
T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede
// Integrate Your World //
From | Date | Subject | |
---|---|---|---|
Next Message | Marco Colombo | 2007-05-15 12:04:09 | Re: a few questions on backup |
Previous Message | Magnus Hagander | 2007-05-15 07:19:46 | Re: dns less connection |