熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

不使用function計算給定兩個日期之間的工作日個數

2022-06-13   來源: JSP教程 

  
  可能這就是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
  代碼
  select start_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
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19526.html
  • 上一篇文章:

  • 下一篇文章:
  • 推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.