CREATE OR REPLACE FUNCTION xxx_get_no_days (p_date_start DATE,
p_date_end DATE)
RETURN NUMBER
AS
l_no_of_days NUMBER := NULL;
BEGIN
SELECT COUNT ( * )
INTO l_no_of_days
FROM (SELECT date_extraction, TO_CHAR (date_extraction, 'DAY')
FROM ( SELECT TO_DATE (p_date_start, 'DD-MON-RRRR')
+ LEVEL
- 1
date_extraction
FROM DUAL
CONNECT BY LEVEL <
(TO_DATE (p_date_end, 'DD-MON-RRRR')
- TO_DATE (p_date_start,
'DD-MON-RRRR'))
+ 2)
WHERE TRIM (TO_CHAR (date_extraction, 'DAY')) NOT IN
('SATURDAY', 'SUNDAY'));
RETURN l_no_of_days;
EXCEPTION
WHEN OTHERS
THEN
RETURN 0;
END xxx_get_no_days;
No comments:
Post a Comment