原 Oracle将秒转换为时分秒的格式
简介
在Oracle中,将秒转换为时分秒(HH24:MI:SS)格式,可以通过多种方法实现
1 2 3 4 5 6 7 8 9 10 11 12 | -- 3665: 01:01:05 -- 90135 25:02:15 -- 8643735 100days 01:02:15 SELECT TO_CHAR(INTERVAL '1' SECOND * 8643735, 'HH24:MI:SS') FROM DUAL; SELECT LTRIM(substr(TO_CHAR(INTERVAL '1' SECOND * 8643735, 'HH24:MI:SS'),1,19),'+0') FROM DUAL; SELECT (case when length(TRUNC(SEC / 3600))>2 THEN TRUNC(SEC / 3600)||'' ELSE LPAD(TRUNC(SEC / 3600), 2, '0')||'' END) ||':'||LPAD(TRUNC(MOD(SEC, 3600) / 60), 2, '0') ||':'||LPAD(MOD(SEC, 60), 2, '0') AS seconds FROM (SELECT 3665 AS SEC FROM DUAL); |