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

From David Fetter
Subject Re: Is there a better way to do this?
Date
Msg-id 20070829161537.GA31614@fetter.org
Whole thread Raw
In response to Is there a better way to do this?  (Wei Weng <wweng@kencast.com>)
List pgsql-general
On Tue, Aug 28, 2007 at 04:59:46PM -0400, Wei Weng wrote:
> 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';

This seems like a lot of extra work.

SELECT now() + 5 * INTERVAL '1 day';

does a similar trick, and is quite clear as to what it does :)

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778        AIM: dfetter666
                              Skype: davidfetter

Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate

pgsql-general by date:

Previous
From: "Hiroshi Saito"
Date:
Subject: Re: postgresql connection string to Vb.NET
Next
From: Curtis Scheer
Date:
Subject: Re: postgresql connection string to Vb.NET