1、获取当天是星期几:select to_char(sysdate,'D') from dual; --星期天为1,星期一为2,类推.......
2、获取 两个时间段间的 工作日:
select start_date, end_date,
end_date - start_date +1
- (trunc(end_date,'IW') - trunc(start_date,'IW')+7)/7*2
+ (case TO_NUMBER(to_char(start_date,'D')) when 7 then 0 when 1 then 1 else 0 end)
+ (case TO_NUMBER(to_char(end_date,'D')) when 7 then 1 when 1 then 0 else 2 end) as day
FROM (SELECT
TO_DATE('2024-09-21', 'YYYY-MM-DD') start_date,
TO_DATE('2024-09-30', 'YYYY-MM-DD') end_date from dual);
Oracle求两个日期之间工作日天数
于 2024-09-27 09:11:46 首次发布