create or replace function F_GET_TIME(timeType in varchar2) return date as nowTime date; begin if timeType = '1' then select case when to_char(sysdate, 'hh24') > 8 then to_date(to_char(sysdate, 'yyyy-MM-dd') || ' 08:00:00', 'yyyy-mm-dd hh24:mi:ss') else to_date(to_char(sysdate-1, 'yyyy-MM-dd')|| ' 08:00:00', 'yyyy-mm-dd hh24:mi:ss') end into nowTime from dual; else select case when to_char(sysdate, 'hh24') > 8 then to_date(to_char(sysdate+1, 'yyyy-MM-dd')|| ' 08:00:00', 'yyyy-mm-dd hh24:mi:ss') else to_date(to_char(sysdate, 'yyyy-MM-dd')|| ' 08:00:00', 'yyyy-mm-dd hh24:mi:ss') end into nowTime from dual; end if; return (nowTime); end F_GET_TIME;