oracle计算两个时间的差值(XX天XX时XX分XX秒)
时间:2021-07-01 10:21:17
帮助过:4人阅读
OR REPLACE FUNCTION F_GET_DIFF_TIME(START_TIME
IN DATE,
END_TIME IN DATE)
RETURN VARCHAR2 IS
DIFF_TIME VARCHAR2(
50);
BEGIN
SELECT TDAY
|| ‘天‘ || THOUR
|| ‘时‘ || TMINUTE
|| ‘分‘ || ROUND((TT
- TMINUTE)
* 60)
|| ‘秒‘ INTO DIFF_TIME
FROM (
SELECT TDAY,
THOUR,
TRUNC((TT - THOUR)
* 60) TMINUTE,
(TT - THOUR)
* 60 TT
FROM (
SELECT TDAY,
TRUNC((TT - TDAY)
* 24) THOUR,
(TT - TDAY)
* 24 TT
FROM (
SELECT TO_NUMBER(END_TIME
- START_TIME)
AS TT,
TRUNC(TO_NUMBER(END_TIME - START_TIME))
AS TDAY
FROM (
SELECT START_TIME, END_TIME
FROM dual))));
RETURN DIFF_TIME;
END;
输出的格式为上图;
oracle计算两个时间的差值(XX天XX时XX分XX秒)
标签:run creat src star png http oracl pre oracle