Basically I need help in writing a query for next business day delivery and holidays also needs to be considered. I also have a calendar table that have all holiday until 2030. A classic example that I have,
let say today is 7/1/2011 which is a Friday. Obviously next business day is a Monday but it falls on 7/4/2011 which is a holiday.
So its next business day should be 7/5/2011.
So when the report for today pulls up, all deliveries scheduled for 7/2 Sat, 7/3 Sun and 7/4 Mon should all be on a new delivery date of 7/5/2011.
I need help in creating a CASE statement to figure out that if it's a Friday, how will it automatically check the Saturday and Sunday.
Or if next day is a holiday, how will it also add the day of the holiday to be delivered on the next business day?
These are a few scenarios that came to mind that I also need help:
Scenario 1
Is @DeliveryDate = Fri
If yes, + 3 days --Mon
Also get deliveries for Sat and Sun to be Mon deliveries
Scenario 2
Is --Is @DeliveryDate = Fri
--If yes, + 3 days --Mon
--Also get deliveries for Sat and Sun to be Mon deliveries
falls on a Holiday, + 1 day --Tue
Also get deliveries for the Holiday to be delivered the next day
Scenario 3
Is @DeliveryDate between Mon - Thur
If yes, + 1 day
Scenario 4
Is --Is @DeliveryDate between Mon - Thur
--If yes, + 1 day
falls on a Holiday, + 1 day
If that falls on a Fri, follow Fri step above
Also get deliveries for the Holiday to be delivered the next day
I apologize if it's hard to understand. Just let me know so I can explain further.
Again any input will be valuable to me to learn more about this technology.
Thank you in advance,
Louie