可能这就是Oracle的work_days函数的算法吧 Calculating Working Days Without Using a Function This tip comes from Mike Selvaggio Senior DB Architect and DBA at Orsel Consulting Inc in North Brunswick NJ If you need to calculate working days between two dates and you cant create the Oraclerecommended working days function here is SQL that can accomplish the same task: SQL> set linesize SQL> desc date_test Name Null? Type START_DT DATE END_DT DATE SQL> select * from date_test SQL> / START_DT END_DT DEC DEC DEC DEC DEC DEC DEC DEC SQL> select start_dt end_dt end_dt start_dt age work_days(start_dt end_dt) from date_test; START_DT END_DT AGE WORK_DAYS(START_DTEND_DT) DEC DEC DEC DEC DEC DEC DEC DEC SQL> get workingdays 代码 selectstart_dt end_dt trunc(end_dt start_dt) age (trunc(end_dt start_dt) ( (case WHEN (to_number(to_char(start_dtD) )) > trunc(end_dt start_dt)+ THEN ELSE trunc( (trunc(end_dt start_dt) (to_number(to_char(start_dtD) ))) / ) + END) + (case WHEN mod(to_char(start_dtD)) > trunc(end_dt start_dt) THEN ELSE trunc( (trunc(end_dtstart_dt) (mod(to_char(start_dtD))+)) / ) + END) ) ) workingdays from date_test SQL> / START_DT END_DT AGE WORKINGDAYS DEC DEC DEC DEC DEC DEC DEC DEC |