Daily Archives: September 7, 2013

Adobe LiveCycle FormCalc Example – Calculating Business Days

Recently I taught an Adobe Livecycle forms course where one of the students asked me to cobble together some FormCalc code that would calculate X business days from a user-entered date.

This was the result:

var startdate = Date2Num($,"YYYY-MM-DD");
var bizdays = 10;
var modifier = 0;

// figure out modifier
for i=1 upto bizdays step 1 do
 var day = Date2Num($,"YYYY-MM-DD") + i;
 var dayOfWeek = Num2Date(day,"EEE");
 if (dayOfWeek == "Sat" or dayOfWeek == "Sun") then
   modifier = modifier + 1;
 endif
endfor

var enddate =  Date2Num($,"YYYY-MM-DD") +  bizdays + modifier;

Date2 = Num2Date(enddate,"YYYY-MM-DD");