Skip to content
Advertisement

count business days in calculation

Continuing from my previous question: case when date column is greater than sysdate then ‘Y’

One thing I forgot to consider was including working days in the calculation.

Here is the query:

So I need to exclude Saturday and Sunday in the calculation above.

I tried to add this in the where clause:

But the calculation does not seem to be working.

If I take vp.eta_date – 5, and I’ll use December 22, 2021 for example. I should get the following date:

But I am getting December 17th.

This of course leads me to believe that what I tried is not working.

How do I fix this?

Advertisement

Answer

You can compare the date to the date at the start of the ISO week and then increase the number of days depending on which day of the week it is:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement