Is there a better way to do this? - Mailing list pgsql-general

From Wei Weng
Subject Is there a better way to do this?
Date
Msg-id 46D48CC2.1080105@kencast.com
Whole thread Raw
Responses Re: Is there a better way to do this?  (Martijn van Oosterhout <kleptog@svana.org>)
Re: Is there a better way to do this?  (Michael Glaesemann <grzm@seespotcode.net>)
Re: Is there a better way to do this?  (Osvaldo Rosario Kussama <osvaldo_kussama@yahoo.com.br>)
Re: Is there a better way to do this?  ("Rodrigo De León" <rdeleonp@gmail.com>)
Re: Is there a better way to do this?  ("D. Dante Lorenso" <dante@lorenso.com>)
Re: Is there a better way to do this?  (David Fetter <david@fetter.org>)
List 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


pgsql-general by date:

Previous
From: "Marko Kreen"
Date:
Subject: Re: Out of Memory - 8.2.4
Next
From: Ben
Date:
Subject: autovacuum not running