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
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
message can get through to the mailing list cleanly