Problem with date calculation - Mailing list pgsql-general

From Patrick FICHE
Subject Problem with date calculation
Date
Msg-id 85058ADF852DD5118FD50002A528A5B6079A14@SERVEUR
Whole thread Raw
Responses Re: Problem with date calculation  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
Hi,

I'm a newbie to Postgresql and have a problem manipulating dates in a
function...

In fact, I want a function to add some days to the current date and return
the result date.

My code would be something like :

/***************************************************************************
*********/
CREATE OR REPLACE FUNCTION AddDay( int ) RETURNS timestamp AS '

DECLARE
_INTdays ALIAS FOR $1;

_DTcurrent timestamp;

BEGIN

_DTcurrent := NOW() + interval ''_INTdays days'';
RETURN _DTcurrent;

END'
LANGUAGE 'plpgsql';
/***************************************************************************
*********/

I know there is an error in the date calculation but don't know how to
calculate it....

Thanks for your help.

Patrick Fiche



Patrick Fiche
email : patrick.fiche@aqsacom.com
tél : 01 69 29 36 18


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Permissions for system tables
Next
From: Stephan Szabo
Date:
Subject: Re: Problem with date calculation