SQL>
SQL> CREATE OR REPLACE FUNCTION bizdays_between (
2 start_date IN DATE, end_date IN DATE)
3 RETURN INTEGER
4 IS
5 v_sundays INTEGER :=
6 NEXT_DAY (end_date - 7, 'SUNDAY') -
7 NEXT_DAY (start_date - 1, 'SUNDAY');
8
9 v_saturdays INTEGER :=
10 NEXT_DAY (end_date - 7, 'SATURDAY') -
11 NEXT_DAY (start_date - 1, 'SATURDAY');
12 BEGIN
13 RETURN (
14 end_date -
15 start_date -
16 (v_sundays + v_saturdays)/7 -
17 1
18 );
19 END;
20 /
Function created.
SQL>
|