create or replace function Add_Times (d1 in date,NewTime in date) return date is hh number. mm number. ss number. hours number. dResult date. begin
-- 下面依次取出时、分、秒
0select to_number(to_char(NewTime,?HH24?)) into hh from dual. 0select to_number(to_char(NewTime,?MI?)) into mm from dual. 0select to_number(to_char(NewTime,?SS?)) into ss from dual.
-- 换算出NewTime中小时总和
hours := (hh (mm / 60) (ss / 3600))/ 24.
-- 得出时间相加后的结果
0select d1 hours into dResult from dual. return(dResult). end Add_Times.
-- 测试用例
-- 0select Add_Times(sysdate,to_date (?2004-12-06 03:23:00?,?YYYY-MM-DD HH24:MI:SS?)) from dual