ORACLE判断两个日期间隔几个工作日
方法:使用存储过程
/**
* 判断两个日期间隔几个工作日
*/
CREATE OR REPLACE FUNCTION "FUN_BETWEENDAYS"(start_dt date, end_dt date)
RETURN INT IS
t_days INT;
BEGIN
SELECT (TRUNC(end_dt - start_dt) - ((CASE
WHEN (8 - to_number(to_char(start_dt, 'D'))) >
TRUNC(end_dt - start_dt) + 1 THEN
0
ELSE
trunc((TRUNC(end_dt - start_dt) -
(8 - to_number(to_char(start_dt, 'D')))) / 7) + 1
END) + (CASE
WHEN MOD(8 - to_char(start_dt, 'D'), 7) >
TRUNC(end_dt - start_dt) - 1 THEN
0
ELSE
TRUNC((TRUNC(end_dt - start_dt) -
(MOD(8 - to_char(start_dt, 'D'), 7) + 1)) / 7) + 1
END)))
INTO t_days
FROM dual;
RETURN t_days;
END FUN_BETWEENDAYS;
写在最后
哪位大佬如若发现文章存在纰漏之处或需要补充更多内容,欢迎留言!!!
相关推荐:
本文来自博客园,作者:Marydon,转载请注明原文链接:https://www.cnblogs.com/Marydon20170307/p/7490791.html