Re: Is there a better way to do this?
От | Michael Glaesemann |
---|---|
Тема | Re: Is there a better way to do this? |
Дата | |
Msg-id | F35D61FB-62B6-4320-9501-96138F070EFA@seespotcode.net обсуждение исходный текст |
Ответ на | Is there a better way to do this? (Wei Weng <wweng@kencast.com>) |
Ответы |
Re: Is there a better way to do this?
Re: Is there a better way to do this? |
Список | pgsql-general |
On Aug 28, 2007, at 15:59 , Wei Weng wrote: > I don't really like this implementation. Is there a more concise > way to do this? create or replace function add_days(timestamp, int) returns timestamp language sql as $body$ select $1 + $2 * interval '1 day' $body$; Note that interval '1 day' is not equal to interval '24 hours'. '1 day' can be 23 or 25 hours across daylight saving time boundaries. If you mean 24 hours (which you're getting with your 24 * 3600 * interval '2 second'), you could do create or replace function add_24_hour_intervals(timestamp, int) returns timestamp language sql as $body$ select $1 + $2 * interval '24 hours'; $body$; Do you *really* want timestamp without time zone? It's not like you're gaining any performance or decreasing storage requirements. Unless you have a reason for *not* using with time zone, I'd recommend using timestamp with time zone. Hope this helps. Michael Glaesemann grzm seespotcode net
В списке pgsql-general по дате отправления: