angoca / db2tools

Set of routines that can ease your daily work.
GNU General Public License v2.0
1 stars 0 forks source link

Timestamp diff with millis #22

Open angoca opened 10 years ago

angoca commented 10 years ago

CREATE OR REPLACE FUNCTION utcmillis (in db2ts timestamp) returns bigint language sql deterministic no external action return ( bigint((days(db2ts - current timezone) - days('1970-01-01-00.00.00.000000')) * 86400 + midnight_seconds(db2ts - current timezone))*1000 + microsecond(db2ts)/1000 );

angoca commented 10 years ago

https://stackoverflow.com/questions/15094186/how-can-i-convert-db2-timestamp-to-utc-milliseconds