Procedure GZR (v_nowdate in varchar2) as???????????????????????? v_firstsaturday varcha2 (10);???????????????????????? ?? v_outdate date;??????????????????????? ????????? v_countworkday number (10);???????????????????? ?????????????????????????? ??????????????????????? SELECT to_CHAR (NEXT_DAY (Concat (v_nowdate, ' 01 '),' YYYYMMDD '), 1) -1,' DD ')?????? V???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????? ;????????????????????????? ?? ?????? v_countworkday: = to_number (v_firststsaturday) -1;????????????????? ?????? loop????????????????????? ??????? ???????????? v_outdate: = to_date (Concat (v_nowdate, v_firstsaturday 7), 'YYYYMMDD');???????????? ? ????? if ?? v_outdate
YYYMM '),' 01 '),' YYYYMMDD ') Then?????????????????????? ?????????
?????????????????????????? ????????????????
??? v_countworkday: = v_countworkday 5;???????????????????????? ?
??? Else??????????????????????? ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??? v_countworkday: = v_countworkday 5-to_number (v_outdate-to_date (concat (to_char (add_months)
, 1), 'YYYYMM'), '01'), 'YYYYYMMDD'));??????????????? ?????????????????????????? ???????????????????
?? End if;??????????????????????? ?????????????
?? exit when v_outdate> = to_date (Concat (be_char (add_months (sysdate, 1), 'YYYYMM'), '01'), 'YYYYMMDD');?
TEXT? ?? ?? ???????????????????????? ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
-------------------------------------------------- --------------------------------------------------
?? End loop;??????????????????????? ?????????????
?? DBMS_OUTPUT.PUT_LINE (v_countworkday);???????????????????????
End gzr;
Method Two:
Create or replace function get_workingdays (?? ny in varcha2) Return Integer IS / * --------------------------------- -------------------------------------------------- ------- Function Name: Get_WorkingDays Chinese Name: How many working days in the CCP author name: xingping Write time: 2004-05-22 Enter parameters: NY: Ask for the annual month of working days, The format is YYYYMM, such as the 200405 return value: integer value, the number of working days. Algorithm Description:?? 1). List every day in the annual month given by parameters. Here, a table (LJRQ is a table in my library. This table can be accessible, any table or view of the number of recorders is at least 31) to construct a certain month. ? 2). Use these dates and a known day date (2001-12-30 is Sunday), the resulting difference is another die. If the result is before 2001-12-30, then the resulting difference is only a negative number, the resulting value has a value of greater than -6, less than 0, such as -1 represents Saturday, the result of the model plus the results 7, Request 7 model.?? 3). Filter out the result of the result of 0 and 6, then seek count, the result is the number of working days. ?? ---------------------------------------------- -------------------------------------------------- - * / ?? Result integer; begin ?? SELECT COUNT (*) INTO RESULT? FROM (SELECT MOD (q.rq-to_date ('2001-12-30', 'YYYY-MM-DD'), 7), 7) Weekday?????? From (select to_date (NY || T.dd, 'YYYYMMDD') RQ?????????? From (SELECT SUBSTR 100 ROWNUM, 2,2) dd? ?? ?? ?? ?? ?? ?? ?? ?? ??? FROM ljrq z WHERE Rownum <= 31? ?? ?? ?? ?? ?? ?? ?? ???) t? ?? ?? ?? ?? ?? ??? WHERE to_date (ny || t.dd, 'yyyymmdd')? ?? ?? ?? ?? ?? ?? ?? Between to_date (NY, 'YYYYMM')??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??) q?????) a??? where a.weekday not in (0, 6) ;? ?? Return Result; ?? End get_workingdays; method three