I have an sql query that casts 2 dates and checks if they are equal. But even though the dates are equal, i dont get the result.
create or replace
FUNCTION getWorkingDays(
DATE_ONE DATE,
DATE_TWO DATE)
RETURN NUMBER
IS
DAY_COUNT NUMBER := 0;
START_DATE DATE;
END_DATE DATE;
HOL_COUNT NUMBER := 0;
BEGIN
IF(DATE_ONE IS NOT NULL AND DATE_TWO IS NOT NULL) THEN
IF DATE_ONE < DATE_TWO THEN
START_DATE := DATE_ONE;
END_DATE := DATE_TWO;
ELSE
START_DATE := DATE_TWO;
END_DATE := DATE_ONE;
END IF;
WHILE START_DATE < END_DATE
LOOP
IF TO_CHAR(START_DATE,'DY') NOT IN ('SAT','SUN') THEN
DAY_COUNT := DAY_COUNT + 1;
END IF;
SELECT count(*) INTO HOL_COUNT
FROM ATL_JOB_HOLIDAY jh
JOIN ATL_MASTER_JOB mj
ON MJ.MASTER_JOB_ID = JH.MASTER_JOB_ID
WHERE TRUNC(HOLIDAY_DATE) = START_DATE;
IF(HOL_COUNT >0) THEN
DAY_COUNT := DAY_COUNT + 1;
Dbms_Output.put_line('Holiday333 :- IS A HOLIDAY');
END IF;
START_DATE := START_DATE + 1;
END LOOP;
END IF;
RETURN DAY_COUNT;
EXCEPTION
WHEN OTHERS THEN
RETURN NULL;
END getWorkingDays;'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…