问题
Using NetSuite, I am trying to automate the creation of monthly tasks. These tasks will fall on the last day of the month, a day before, and 1,2,3,4,5 days after the last day of the month. But, the tasks can't be due on a weekend, only business days. So if the day falls on a sat or sun the dates have to move up. How can I use my custom record to calculate the next months task dates skipping weekends? Here is a screenshot of the record - see that 10/4 and 10/5 fall on saturday and sunday, how can I have it skip sat and sunday? I used the sql function option to generate the dates and days of the week.
回答1:
I tested the following formula. Replace custbody_date with your field name. This formula should be set in your 'next month' column.
CASE WHEN INSTR(to_char({custbody_date}, 'DAY'),'SATURDAY') != 0
THEN {custbody_date}+2
WHEN INSTR(to_char({custbody_date}, 'DAY'),'SUNDAY') != 0
THEN {custbody_date}+1 ELSE {custbody_date}
END
This should also give you an idea to set the value for 'Next Month Day' (skipping saturday and sunday).
来源:https://stackoverflow.com/questions/25327342/skip-weekends-business-day-tasks-netsuite