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@xxxxxxxxxx> 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 ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match