CREATE FUNCTION EPOCH (
RETURN CAST (DAYS(DB2TIME) - DAYS('1970-01-01') AS INTEGER) * 86400
I understand the epoch to be the number of SECONDS from 1970-01-01, so the above would not result in overflow for dates 30 or so years from now - I haven't done the maths, so don't flame me if I'm wrong :-)
I've included the CAST clause, so that you can change the INTEGER to DOUBLE if you wanted to multiply by 86400000 to get the number of milliseconds. You'd obviously have to change the RETURN type aswell.
Last edited by Damian Ibbotson; 11-26-02 at 11:04.