Skip to content
Advertisement

Simulating NETWORKDAYS returns wrong business days

I created a NETWORKDAYS-like function on sql based on this solution wich returns correctly the business days while the records (BEG and END) are on business days.

But in some cases where BEG or END are “stored” in weekends it counts extra days:

My code does a datediff between BEG and FIN and subtracting weekend days and the holydays stored on the holydays table

How could I handle these cases to correctly count business days?

Advertisement

Answer

you can use calendar table for this purpose. This operation will be very easy with it.

you can even handle bank holidays

Check This and this (Calendar Table)

will get you workdays and then you can make simple join like

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