Unix time from DB2
Here’s one way to obtain the Unix time value (the number of seconds since midnight on January 1, 1970) from a DB2 timestamp:
values(
(days(current_timestamp-current_timezone) - days('1970-01-01') )*86400 +
midnight_seconds(current_timestamp - current_timezone)
)
This can be used in a query directly or wrapped into a simple SQL user-defined function.