How to get difference from two timestamp in DB2?

前端 未结 2 1705
渐次进展
渐次进展 2020-12-12 03:27

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

相关标签:
2条回答
  • 2020-12-12 03:40

    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)
    
    0 讨论(0)
  • 2020-12-12 03:55

    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

    0 讨论(0)
提交回复
热议问题