Skip weekends formula
Skip weekends formula
Hello, I am building a database that will allow a user to set a target delivery date and choose a shipping zone. Based off of this information the program will auto populate the "needs to ship on date." My issue is i can not find a formula to add in the extra two days for the weekend if there is a weekend in the middle. This is what I have so far. Thanks in advance for any help.
- if (input.Shipping_Zone != "-Select-")
- {
- days = ((input.Shipping_Zone).subString(0,1)).toLong();
- if (days > 5)
- {
- days = (days + 2);
- }
- input.Must_Ship_On = (input.Target_Delivery_Date).subDay(days);
- if (input.Must_Ship_On.getDayOfWeek() == 1)
- {
- input.Must_Ship_On = input.Must_Ship_On.subDay(2);
- }
- else if (input.Must_Ship_On.getDayOfWeek() == 7)
- {
- input.Must_Ship_On = input.Must_Ship_On.subDay(1);
- }
- }