Problem with date calculation

From: Patrick FICHE <Patrick(dot)FICHE(at)AQSACOM(dot)COM>
To: "PostgreSQL - General (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Problem with date calculation
Date: 2002-08-26 15:29:51
Message-ID: 85058ADF852DD5118FD50002A528A5B6079A14@SERVEUR
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)fiche(at)aqsacom(dot)com
tél : 01 69 29 36 18

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-08-26 15:37:25 Re: Problem with date calculation
Previous Message Tom Lane 2002-08-26 14:11:05 Re: Permissions for system tables