turtlepatch
Programmer
I need to determine the due date of an order. Orders come in between 18:00 of one day until 17:59 of the next day. Anything between 18:00 and 24:00 counts the next day as day 0. After 24:00 the current day is day zero. I need to show the due date (day 2). I have a formula from Ken Hamady for adding business days to a date. My problem occurs when orders come in on the weekend. Any order coming in after 18:00 on Friday, has day 0 as the next Monday. The calculation works correctly until I have an order come in on Saturday. It counts Saturday as day zero and then adds 2 business days to it and has it due on Tuesday instead of Wednesday. Here is the code I am using:
@time is the order time.
@time2 is 18:00:00
This is the code currently for my due date:
if {@time}< {@time2}
then
(WhileReadingRecords;
DateVar Array Holidays;
DateVar Target:={cd_sfly_order.Created-Date}; // Put your field name in here
NumberVar Add:= 2; // put the number of days here to add (a positive number)
NumberVar Added := 0;
WHILE Added < Add
Do (target := target +1;
if dayofweek (target) in 2 to 6 and not (target in holidays)
then Added:=Added+1
else Added:=Added);
Target)
else
(WhileReadingRecords;
DateVar Array Holidays;
DateVar Target:={cd_sfly_order.Created-Date}; // Put your field name in here
NumberVar Add:= 3; // put the number of days here to add (a positive number)
NumberVar Added := 0;
WHILE Added < Add
Do (target := target +1;
if dayofweek (target) in 2 to 6 and not (target in holidays)
then Added:=Added+1
else Added:=Added);
Target)
Any help would be greatly appreciated.
@time is the order time.
@time2 is 18:00:00
This is the code currently for my due date:
if {@time}< {@time2}
then
(WhileReadingRecords;
DateVar Array Holidays;
DateVar Target:={cd_sfly_order.Created-Date}; // Put your field name in here
NumberVar Add:= 2; // put the number of days here to add (a positive number)
NumberVar Added := 0;
WHILE Added < Add
Do (target := target +1;
if dayofweek (target) in 2 to 6 and not (target in holidays)
then Added:=Added+1
else Added:=Added);
Target)
else
(WhileReadingRecords;
DateVar Array Holidays;
DateVar Target:={cd_sfly_order.Created-Date}; // Put your field name in here
NumberVar Add:= 3; // put the number of days here to add (a positive number)
NumberVar Added := 0;
WHILE Added < Add
Do (target := target +1;
if dayofweek (target) in 2 to 6 and not (target in holidays)
then Added:=Added+1
else Added:=Added);
Target)
Any help would be greatly appreciated.