• <tfoot id='22BYJ'></tfoot>

    <i id='22BYJ'><tr id='22BYJ'><dt id='22BYJ'><q id='22BYJ'><span id='22BYJ'><b id='22BYJ'><form id='22BYJ'><ins id='22BYJ'></ins><ul id='22BYJ'></ul><sub id='22BYJ'></sub></form><legend id='22BYJ'></legend><bdo id='22BYJ'><pre id='22BYJ'><center id='22BYJ'></center></pre></bdo></b><th id='22BYJ'></th></span></q></dt></tr></i><div id='22BYJ'><tfoot id='22BYJ'></tfoot><dl id='22BYJ'><fieldset id='22BYJ'></fieldset></dl></div>

    <small id='22BYJ'></small><noframes id='22BYJ'>

    • <bdo id='22BYJ'></bdo><ul id='22BYJ'></ul>
      <legend id='22BYJ'><style id='22BYJ'><dir id='22BYJ'><q id='22BYJ'></q></dir></style></legend>
      1. SQL 返回两个传入日期之间的工作日数

        SQL to return the number of working days between 2 passed in dates(SQL 返回两个传入日期之间的工作日数)

        <small id='RVt7O'></small><noframes id='RVt7O'>

              • <bdo id='RVt7O'></bdo><ul id='RVt7O'></ul>
                <i id='RVt7O'><tr id='RVt7O'><dt id='RVt7O'><q id='RVt7O'><span id='RVt7O'><b id='RVt7O'><form id='RVt7O'><ins id='RVt7O'></ins><ul id='RVt7O'></ul><sub id='RVt7O'></sub></form><legend id='RVt7O'></legend><bdo id='RVt7O'><pre id='RVt7O'><center id='RVt7O'></center></pre></bdo></b><th id='RVt7O'></th></span></q></dt></tr></i><div id='RVt7O'><tfoot id='RVt7O'></tfoot><dl id='RVt7O'><fieldset id='RVt7O'></fieldset></dl></div>
                  <tbody id='RVt7O'></tbody>

                1. <legend id='RVt7O'><style id='RVt7O'><dir id='RVt7O'><q id='RVt7O'></q></dir></style></legend><tfoot id='RVt7O'></tfoot>

                  本文介绍了SQL 返回两个传入日期之间的工作日数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要编写一个 sql 查询,返回两个给定日期之间的工作日(周一至周五)数.

                  I need to write an sql query that returns the number of Working days (Monday - Friday) between two given dates.

                  我想知道最有效的方法是什么?

                  I was wondering what would be the most efficient way to do this?

                  SELECT           --Start with total number of days including weekends             
                  (DATEDIFF(dd,@StartDate,@EndDate)+1) --Subtact 2 days for each full weekend 
                  (DATEDIFF(wk,@StartDate,@EndDate)*2) --If StartDate is a Sunday, Subtract 1          
                  ELSE 0               END)            --If EndDate is a Saturday, Subtract 1 
                  FROM dual
                  

                  然后,能够从该计数中删除假期(例如圣诞节和节礼日)也会很有帮助.

                  Then it would also be helpful to be able to remove holidays from this count such as christmas day and boxing day.

                  有什么想法吗?

                  推荐答案

                  计算两个日期之间的工作日数的简单方法是:

                  an easy way to calculate to number of weekdays between 2 dates is :

                  SELECT
                  date1,
                  date2,
                  ((date2-date1)-2*FLOOR((date2-date1)/7)-DECODE(SIGN(TO_CHAR(date2,'D')-
                      TO_CHAR(date1,'D')),-1,2,0)+DECODE(TO_CHAR(date1,'D'),7,1,0)-
                      DECODE(TO_CHAR(date2,'D'),7,1,0))*24 as WorkDays
                  FROM
                    tablename
                  ORDER BY date1,date2
                  

                  这篇关于SQL 返回两个传入日期之间的工作日数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

                    <legend id='6vZRJ'><style id='6vZRJ'><dir id='6vZRJ'><q id='6vZRJ'></q></dir></style></legend>
                  1. <i id='6vZRJ'><tr id='6vZRJ'><dt id='6vZRJ'><q id='6vZRJ'><span id='6vZRJ'><b id='6vZRJ'><form id='6vZRJ'><ins id='6vZRJ'></ins><ul id='6vZRJ'></ul><sub id='6vZRJ'></sub></form><legend id='6vZRJ'></legend><bdo id='6vZRJ'><pre id='6vZRJ'><center id='6vZRJ'></center></pre></bdo></b><th id='6vZRJ'></th></span></q></dt></tr></i><div id='6vZRJ'><tfoot id='6vZRJ'></tfoot><dl id='6vZRJ'><fieldset id='6vZRJ'></fieldset></dl></div>

                        <small id='6vZRJ'></small><noframes id='6vZRJ'>

                          <bdo id='6vZRJ'></bdo><ul id='6vZRJ'></ul>
                            <tfoot id='6vZRJ'></tfoot>
                              <tbody id='6vZRJ'></tbody>