17,086
社区成员
发帖
与我相关
我的任务
分享
create or replace function testweek(rq in date) return varchar2
is week varchar2(10);
strrq varchar2(10);
yyyy varchar2(10);
begin
select to_char(rq,'yyyy') into yyyy from dual;
select to_char(rq,'iw') into week from dual;
select to_char(rq,'mm') into strrq from dual;
if week='53' and strrq='01' then
week:=1;
else week:=week+1;
end if;
week:=yyyy||'-'||week;
return(week);
end ;
--try it
select to_char(sysdate,'YYYY-FMWW') from dual;
--try it
select to_char(sysdate,'FMWW') from dual;