orcal函数

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;

 

posted on 2018-07-12 15:19  狗狗汪汪叫  阅读(175)  评论(0编辑  收藏  举报

导航