How to count date difference excluding weekend and holidays in MySQL

后端 未结 5 1950
青春惊慌失措
青春惊慌失措 2020-12-01 12:35

I need to count days (business days) between two dates excluding weekend (most important) and holidays

SELECT DATEDIFF(end_date, start_date) from accounts
         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 13:05

    Try This Code this will Calculate no of days Excluding Weekends

     SELECT
           (DATEDIFF(dd, @StartDate, @EndDate)+1)
          -(DATEDIFF(wk, @StartDate, @EndDate) * 2)
    from test_tbl where date NOT IN (SELECT date FROM holidaydatestable )
    

提交回复
热议问题