Search Postgresql Archives

Is there a better way to do this?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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';

Basically the function takes two parameters, and add the second one (as days) onto the first one (as timestamp without timezone) I don't really like this implementation. Is there a more concise way to do this?

Thanks

Wei


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux