i have a requirement in which i have to get time difference of two timestamp in hours and than later find an average of the hours.
i am using below query to find dif
It's easy, by converting the timestamp to hours as follows:
(24*DAYS(last_modified_datetime)+MIDNIGHT_SECONDS(last_modified_datetime)/3600)
-
(24*DAYS(create_datetime)+MIDNIGHT_SECONDS(create_datetime)/3600)
Use the built-in Db2 function HOURS_BETWEEN()
https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.sql.ref.doc/doc/r0061478.html