清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
create or replace function FUN_GET_WORKTIME(PARAM_DATE IN DATE) return NUMBER is num_worktime number:= 8;--工作总时长 num_mi number:= 60;--60分钟 num_ss number:= 60;--60秒 num_work_begin number:= 8/24 + 30/(24*60);--8:30 num_noon_begin number:= 11/24 + 30/(24*60);--11:30 num_noon_end number:= 12/24;--12:00 num_work_end number:= 17/24;--17:00 num_time number;--时间 num_return number;--返回值 d_init date := to_date('1988-08-08 00:00:00','YYYY-MM-DD hh24:mi:ss'); --初始日期 num_holi NUMBER; num_holi_y NUMBER; BEGIN --查询节假日表holiday select count(1) into num_holi from holiday h where h.holi_day < to_char(PARAM_DATE, 'YYYY-MM-DD'); select count(1) into num_holi_y from holiday h where h.holi_day = to_char(PARAM_DATE, 'YYYY-MM-DD'); num_return := floor(PARAM_DATE - d_init - num_holi); --判断当天是否为节假日 if(num_holi_y >= 1) then num_return := num_return + 0; else num_time := PARAM_DATE - to_date(to_char(PARAM_DATE,'YYYY-MM-DD')||' 00:00:00','YYYY-MM-DD hh24:mi:ss'); --时间在8:30以前至0 if(num_time<=num_work_begin) then num_return := num_return + 0; end if; --时间在8:30到11:30之间 if(num_time > num_work_begin and num_time < num_noon_begin) then num_return := num_return + (num_time - num_work_begin); end if; --时间在11:30到12:00之间 if(num_time > num_noon_begin and num_time<=num_noon_end) then num_return := num_return + (num_noon_begin-num_work_begin); end if; --时间在12:00到17:00之间 if(num_time > num_noon_end and num_time<=num_work_end) then num_return := num_return + (num_time - num_work_begin - (num_noon_end - num_noon_begin)); end if; --时间大于17:00 if(num_time > num_work_end ) then num_return := num_return + (num_work_end - num_work_begin - (num_noon_end - num_noon_begin)); end if; end if; num_return := num_return * num_worktime * num_mi * num_ss; return (num_return); end FUN_GET_WORKTIME;