开发者

PL/SQL time segment calculation

开发者 https://www.devze.com 2022-12-29 20:48 出处:网络
I need to figure how much time passed between 2 times. For example: (14:00:00 - 13:15:00) * 24 = .75 I need this to later on convert KW开发者_Python百科 to KWh, but that\'s not the point.

I need to figure how much time passed between 2 times. For example:

(14:00:00 - 13:15:00) * 24 = .75

I need this to later on convert KW开发者_Python百科 to KWh, but that's not the point.

I can not find out how to do this in PL/SQL.

My date/time fields look like this in the DB:

1/23/2010 21:00:00

I would appreciate any suggestions.

Steve


If you are using 9i above does this give you the expected result?

select extract(hour from numtodsinterval(to_date('14:00:00','HH24:MI:SS') - to_date('13:15:00','HH24:MI:SS'),'DAY'))
||':'|| extract(minute from numtodsinterval(to_date('14:00:00','HH24:MI:SS') - to_date('13:15:00','HH24:MI:SS'),'DAY')) diff
from dual
/

DIFF
------------------

0:45

Extract is detailed here

and numtodsinterval is detailed here

0

精彩评论

暂无评论...
验证码 换一张
取 消