Calculate difference between 2 dates in SQL, excluding weekend days

前端 未结 10 1014
礼貌的吻别
礼貌的吻别 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:26

    • Calculates the difference in days between the two dates
    • Calculates the difference in week numbers and year numbers, subtracts the week numbers and then multiplies the result by 2 to calculate number of non-workdays between the two dates. If year numbers are different calculation of 52 * year difference + week number.

    ((sysdate - ced.created_dt) + ((((to_char(ced.created_dt,'IW') - ((to_char(sysdate,'YY') - to_char(ced.created_dt,'YY'))* 52)) - to_char(to_char(sysdate,'IW')))) * 2)) duration_in_weekdays

提交回复
热议问题