How to get difference from two timestamp in DB2?

前端 未结 2 1709
渐次进展
渐次进展 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)
    

提交回复
热议问题