两个日期间隔三个工作日的sql语句
时间:2021-07-01 10:21:17
帮助过:18人阅读
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
两个日期间隔三个工作日的sql语句
标签:font ase trunc 工作 ber class ace function number