Calculating working days including holidays between dates without a calendar table in oracle SQL

后端 未结 2 814
借酒劲吻你
借酒劲吻你 2021-01-15 05:05

Okay, so I\'ve done quite a lot of reading on the possibility of emulating the networkdays function of excel in sql, and have come to the conclusion that by far the easiest

2条回答
  •  生来不讨喜
    2021-01-15 05:57

    If you can't use a calendar table in Oracle, you might be better off exporting to Excel. Brute force always works.

    Networkdays() "returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays."

    Excluding weekends seems fairly straightforward. Every 7-day period will contain two weekend days. You'll just need to take some care with the leftover days.

    Holidays are a different story. You have to either store them or pass them as an argument. If you could store them, you'd store them in a calendar table, and your problem would be over. But you can't do that.

    So you're looking at passing them as an argument. Off the top of my head--and I haven't had any tea yet this morning--I'd consider a common table expression or a wrapper for a stored procedure.

提交回复
热议问题