Db/Oracle
oracle 평일 구하는 함수
seongsland
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
출처를 참조로 조금 수정 했습니다.