Posted by nick @ 16:55 on December 19th 2008

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.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment