ORACLE 시간차 환산 (초->시간 / 시간->초)
2016. 3. 8. 13:44ㆍ99. 정리전 - IT/15. SQL 따라잡기
ORACLE SQL
시간차를 초로 환산
SELECT systimestamp(3) - tm AS interval
, EXTRACT(DAY FROM systimestamp(3) - tm) *24*60*60
+ EXTRACT(HOUR FROM systimestamp(3) - tm) *60*60
+ EXTRACT(MINUTE FROM systimestamp(3) - tm) *60
+ EXTRACT(SECOND FROM systimestamp(3) - tm) AS second
FROM (SELECT TO_TIMESTAMP('14/01/13 17:40:33.751', 'yy/mm/dd hh24:mi:ss.ff3') tm FROM dual)
초를 시간으로 환산
SELECT (TRUNC(4215/(60*60))) ||'시간'||
LPAD(TRUNC(MOD((4215/60),60)),2,0)||'분'||
LPAD(TRUNC(MOD(4215,60)),2,0) ||'초' AS BAT_DTIME
FROM DUAL