FUN_SYS_GET_NUM_WEEK(时间在第几周)2

来源:互联网 发布:春雨撕拉面膜知乎 编辑:程序博客网 时间:2024/04/28 22:40

 --vv_week_start_flag = '1' means the first day of week is monday
    elsif vv_week_start_flag = '1' then
      if vv_day_flag = '2' then
        vi_num_week := vv_year || lpad(to_char(ceil((vd_date - vd_first_day + 1)/7)),2,'0');
      elsif vv_day_flag = '3' then
        vi_num_week := vv_year || lpad(to_char(ceil((vd_date - vd_first_day - 5)/7) + 1),2,'0');
      elsif vv_day_flag = '4' then
        vi_num_week := vv_year || lpad(to_char(ceil((vd_date - vd_first_day - 4)/7) + 1),2,'0');
      elsif vv_day_flag = '5' then
        vi_num_week := vv_year || lpad(to_char(ceil((vd_date - vd_first_day - 3)/7) + 1),2,'0');
      elsif vv_day_flag = '6' then
        vi_num_week := vv_year || lpad(to_char(ceil((vd_date - vd_first_day - 2)/7) + 1),2,'0');
      elsif vv_day_flag = '7' then
        vi_num_week := vv_year || lpad(to_char(ceil((vd_date - vd_first_day - 1)/7) + 1),2,'0');
      elsif vv_day_flag = '1' then
        vi_num_week := vv_year || lpad(to_char(ceil((vd_date - vd_first_day)/7) + 1),2,'0');
      end if;
      if vv_last_day_flag <> '1' and vd_date >= vd_last_day - to_number(vv_last_day_flag) + 2 then
        vi_num_week := vv_next_year || '01';
      end if;
   /*   vi_num_week := to_char(vd_date, 'yyyyiw');*/
    end if;

    return vi_num_week;

exception
    when others then
        return null;
end fun_sys_get_num_week;

0 0
原创粉丝点击