create or replace function fn_get_myjob_interval(now date)return date is Result date; v_n_min number; v_n_hour number; v_n_all date; begin v_n_min:=to_number(to_char(now,'mi')); v_n_hour:=to_number(to_char(now,'hh24')); if v_n_hour>=20then result:=trunc(sysdate+1)+1/3; else v_n_all:=trunc(sysdate); if v_n_min>=0 and v_n_min<15then result:=v_n_all+(v_n_hour*60+15)/1440; elsif v_n_min>=15 and v_n_min<30then result:=v_n_all+(v_n_hour*60+30)/1440; elsif v_n_min>=30 and v_n_min<45then result:=v_n_all+(v_n_hour*60+45)/1440; else result:=v_n_all+(v_n_hour+1)*60/1440; end if; end if; return(Result); end fn_get_so2do_job_interval;