CREATE OR REPLACE FUNCTION workdays_today(
i_fromdate IN DATE, -- 起始日期
i_toDate IN DATE -- 截止日期
)
RETURN NUMBER
IS
v_day NUMBER(18,0);
v_fromdate DATE;
v_todate DATE;
BEGIN
IF i_fromdate <= i_todate THEN
v_fromdate := i_fromdate;
v_todate := i_todate;
ELSE
v_fromdate := i_todate;
v_todate := i_fromdate;
END IF;
SELECT COUNT(cdays)-1 INTO v_day FROM (
SELECT v_fromdate + level - 1 as cdays FROM dual
CONNECT BY level <=
(v_todate - v_fromdate + 1 ) ) T
WHERE to_char(cdays,'D') <> 1
AND to_char(cdays,'D') <> 7;
RETURN v_day;
END;
i_fromdate IN DATE, -- 起始日期
i_toDate IN DATE -- 截止日期
)
RETURN NUMBER
IS
v_day NUMBER(18,0);
v_fromdate DATE;
v_todate DATE;
BEGIN
IF i_fromdate <= i_todate THEN
v_fromdate := i_fromdate;
v_todate := i_todate;
ELSE
v_fromdate := i_todate;
v_todate := i_fromdate;
END IF;
SELECT COUNT(cdays)-1 INTO v_day FROM (
SELECT v_fromdate + level - 1 as cdays FROM dual
CONNECT BY level <=
(v_todate - v_fromdate + 1 ) ) T
WHERE to_char(cdays,'D') <> 1
AND to_char(cdays,'D') <> 7;
RETURN v_day;
END;