Calculate difference between 2 dates in SQL, excluding weekend days

前端 未结 10 1019
礼貌的吻别
礼貌的吻别 2020-12-04 01:34

I would like to build an SQL query which calculates the difference between 2 dates, without counting the week-end days in the result.

Is there any way to format the

10条回答
  •  借酒劲吻你
    2020-12-04 02:18

    You can try this:

    SELECT
        Id,
        DATEDIFF(d, datefrom, dateto) AS TotDays,
        DATEDIFF(wk, datefrom, dateto) AS Wkds,
        DATEDIFF(d, datefrom, dateto) - DATEDIFF(wk, datefrom, dateto) AS Days
    FROM
        YOURTABLE
    

提交回复
热议问题