FUN_SYS_GET_CALENDAR_WEEK(4)

来源:互联网 发布:windows xp好还是7好 编辑:程序博客网 时间:2024/04/28 00:21
 /*
            desription Get the week of before first sunday.
            parameter vd_first_week_date
            */
            if vd_deal_date < vd_first_week_date then
                /*
                desription Get the last week of last year when first week start with Jan 1st.
                */
                if to_char(to_date(to_char(vd_deal_date,'yyyy') - 1||'0101','yyyymmdd'),'D') = '1' then
                    ov_return := to_char(to_date(to_char(vd_deal_date,'yyyy') - 1||'1231','yyyymmdd'),'yyyyww');
                else
                    /*
                    desription Get the date of the first sunday of last year.
                    */
                    vi_loop_num := 1;
                    loop
                        if vi_loop_num > 6 then
                            exit;
                        else
                            if to_char(to_date(to_char(vd_deal_date,'yyyy') - 1||'0101','yyyymmdd')+vi_loop_num,'D') = 1 then
                                vd_first_week_date1 := to_date(to_char(vd_deal_date,'yyyy') - 1||'0101','yyyymmdd')+vi_loop_num;
                                exit;
                            else
                                vi_loop_num := vi_loop_num+1;
0 0
原创粉丝点击