Hi there,
I haven't checked out how to do this using FormCalc, but with JavaScript it is do-able.
One way to do it would be having a loop to iterate as many times it needs to end up adding 30 working days. This technically will not consider public holidays, if you want to take it in consideration you will need to add in some more details.
So here's how I'd do it:
//Verify that the value of the date field is different than null
if (initDate.rawValue != null){
//Split the year/month/day of the date to help create a Date object
var arrValues = initDate.rawValue.split("-"),
//Call the date constructor using the values stored in an array (month are index based which requires a -1)
startDate = new Date(arrValues[0], arrValues[1]-1, arrValues[2]),
//The weekend "Day" values are 6 and 0 (saturday and sunday)
arrWeekend = ["0", "6"],
//Use initialDay if you want to count the selected date within the 30 working days
initialDay = arrWeekend.indexOf(startDate.getDay().toString()) == -1 ? 1 : 0;
//Loop until work days reach 30 ::: intWorkDays < 30
//and if the 30th day ends in the weekend, skip to next working day ::: || (intWorkDays == 30 && arrWeekend.indexOf(startDate.getDay().toString()) > -1)
for (var i = 0, intWorkDays = 0; intWorkDays < 30 || (intWorkDays == 30 && arrWeekend.indexOf(startDate.getDay().toString()) > -1); i=0){
//Use the following loop statement if you wish to use initialDay
////for (var i = 0, intWorkDays = initialDay; intWorkDays < 30 || (intWorkDays == 30 && arrWeekend.indexOf(startDate.getDay().toString()) > -1); i=0){
//Verify that the current day is not a weekend day
if (arrWeekend.indexOf(startDate.getDay().toString()) == -1){
//Any working day will result in incrementing the working day variable
intWorkDays +=1;
}
//For each iteration, increment the date by 1 day
startDate.setDate(startDate.getDate() + 1);
}
//Print out the resulting value
util.printd("yyyy-mm-dd", startDate);
}
You may want to verify the comments I've written to understand and alter the code to your liking.
I hope this will help, let me know.