时间:2021-07-01 10:21:17 帮助过:5人阅读
函数:
CREATE OR REPLACE FUNCTION count_weekend(start_date IN DATE, end_date IN DATE)
RETURN NUMBER IS V_COUNT INT;
BEGIN
SELECT count(*) INTO V_COUNT
FROM (SELECT start_date + num - 1,
TO_CHAR(end_date + num - 1, ‘DAY‘) as t_date2
FROM (SELECT rownum as num FROM obj)
WHERE start_date + num - 1 <= end_date)
WHERE t_date2 in (‘星期六‘, ‘星期日‘);
IF NVL(V_COUNT,0) > 0 THEN
RETURN (V_COUNT);
ELSE
RETURN (0);
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN (-1);
END ;
Oracle,获取2个日期间有多少个周六和周日
标签:div fun nbsp number start blog ace gpo day