create or replace function get_week_month(v_date in Date)
return varchar2
as
v_day1 number ;
v_month number ;
v_week2 varchar(255);
begin
select to_char(v_date,'DY') into v_week2 from dual;
select to_char(v_date,'W') into v_day1 from dual;
select trunc(to_char(v_date,'mm')) into v_month from dual;
if (v_week2='星期五' or v_week2='星期六' or v_week2='星期日') and v_day1=1 then
v_month:=v_month-1;
select to_char(last_day(ADD_MONTHS(v_date,-1)),'W') into v_day1 from dual;
return v_month||'月 '||v_week2||'第 '||v_day1||' 周';
elsif (v_week2='星期一'or v_week2='星期二' or v_week2='星期三') and v_day1=5 then
v_month:=v_month+1;
v_day1:=1;
return v_month||'月 '||v_week2||'第 '||v_day1||' 周';
else
return v_month||'月 '||v_week2||'第 '||v_day1||' 周';
end if;
end get_week_month;
获取日期在当月中第几周
最新推荐文章于 2024-04-04 01:29:41 发布