2012. 5. 23. 10:51
반응형

oracle 평일 구하는 함수

create or replace function count_business_days (

   start_date   in   date,

   end_date     in   date

)

   return number

is

   currdate        date          := start_date;

   theday          varchar2 (10);

   countbusiness   number        := 0;

begin

   if end_date - start_date <= 0

   then

      return (0);

   end if;


   loop

      currdate := to_date (currdate + 1);

      exit when currdate > end_date;

      theday := to_char (currdate, 'D');


      if theday <> '1' and theday <> '7'

      then

         countbusiness := countbusiness + 1;

      end if;

   end loop;


   return (countbusiness);

end;


출처 : http://blog.naver.com/json2811?Redirect=Log&logNo=90106238401

출처를 참조로 조금 수정 했습니다.

반응형

'Db > Oracle' 카테고리의 다른 글

쿼리 내용으로 쿼리실행  (1) 2013.06.05
공휴일을 제외한 두 날짜의 차이 구하기  (2) 2012.09.12
oracle server 설치 및 삭제  (1) 2012.02.29
oracle server character set 변경  (0) 2012.02.16
백업및 복구  (1) 2012.02.16
Posted by seongsland