Re: Is there a better way to do this?
| От | David Fetter |
|---|---|
| Тема | Re: Is there a better way to do this? |
| Дата | |
| Msg-id | 20070829161537.GA31614@fetter.org обсуждение |
| Ответ на | Is there a better way to do this? (Wei Weng <wweng@kencast.com>) |
| Список | 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 по дате отправления: