Is there a better way to do this?

From: Wei Weng <wweng(at)kencast(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Is there a better way to do this?
Date: 2007-08-28 20:59:46
Message-ID: 46D48CC2.1080105@kencast.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all

I want to implement something like the following:

CREATE OR REPLACE FUNCTION AddDays
(TIMESTAMP WITHOUT TIME ZONE
, INT)
RETURNS TIMESTAMP WITHOUT TIME ZONE AS '
DECLARE
time ALIAS FOR $1;
days ALIAS FOR $2;
BEGIN
RETURN time+days*24*3600*''1 second''::INTERVAL;
END;
' LANGUAGE 'plpgsql';

Basically the function takes two parameters, and add the second one (as
days) onto the first one (as timestamp without timezone)
I don't really like this implementation. Is there a more concise way to
do this?

Thanks

Wei

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Amiel 2007-08-28 21:01:05 Re: Out of Memory - 8.2.4
Previous Message Tom Lane 2007-08-28 20:55:05 Re: Out of Memory - 8.2.4