ORACLE判断两个日期间隔几个工作日
时间:2021-07-01 10:21:17
帮助过:8人阅读
*
* 判断两个日期间隔几个工作日
*/
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;
ORACLE判断两个日期间隔几个工作日
标签:star art mod function char 存储 ret 存储过程 time