How to convert the time difference to hours(with 2 decimal place) in derby?

有些话、适合烂在心里 提交于 2019-12-11 04:46:41

问题


I am using timestampdiff in derby db to retrieve the time difference between 2 time: startdate, and enddate. e.g.

startdate = 2010-02-23 02:59:52.045 enddate = 2010-02-23 03:45:39.898

select {fn timestampdiff(SQL_TSI_HOUR, startdate, enddate)} as diff 

I would like to know how can I get the time diff in hours, e.g. 0.25, etc?

Thank you.


回答1:


select {fn timestampdiff(SQL_TSI_MINUTE, startdate, enddate)}/60 as diff 

and I would call the variables startdatetime and enddatetime.




回答2:


Specifically for HOURS difference use "SQL_TSI_HOUR"

select {fn timestampdiff(SQL_TSI_HOUR, startdate, enddate)} as diff 

see here: https://docs.faircom.com/doc/sqlref/33476.htm



来源:https://stackoverflow.com/questions/2468428/how-to-convert-the-time-difference-to-hourswith-2-decimal-place-in-derby

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!