Have to calculate number of working days
800528Jul 11 2012 — edited Jul 12 2012hi,
have a function using this function i have to calculate the work days
the functions is
CREATE OR REPLACE FUNCTION XXXXXXXXXXX (
pdate IN DATE
, pdays IN NUMBER
)
RETURN DATE
AS
CURSOR c
IS
SELECT calendar_date
, ROWNUM
FROM bom_calendar_dates
WHERE calendar_code = 'DEP CAL'
AND TO_CHAR (calendar_date, 'YYYY') = TO_CHAR (pdate, 'YYYY')
AND seq_num IS NOT NULL
AND TO_CHAR (calendar_date, 'DY') NOT IN ('SAT', 'SUN')
AND calendar_date <= TRUNC (pdate)
ORDER BY 1 DESC;
BEGIN
IF TO_CHAR (pdate, 'DY') NOT IN ('SAT', 'SUN')
THEN
FOR i IN c
LOOP
IF i.ROWNUM = pdays
THEN
RETURN (i.calendar_date);
END IF;
END LOOP;
END IF;
END;
use this logic have get the number of working day
which we will be used in the package which procedure a xls report ...
thanks in advance...
please help in regard....