Skip to main content
May 23, 2016
Question

Calculating Dates

  • May 23, 2016
  • 2 replies
  • 377 views

I need to calculate a new date based off another date and exclude weekends.

For example I have a field called "Date Position Closed". If I enter a date of 5/20/2016 it should populate another field called "Target Date QRB" with 9/27/2016. Which is 90 business days after the initial date.

So far this is what I have, but it calculates based off all calendar days:

var strStart = this.getField("DatePositionClosed").value;

if(strStart.length)

{

  var DatePositionClosed = util.scand("m/dd/yyyy",strStart);

  var oneDay = 24 * 60 * 60 * 1000;

  var dueMillis = DatePositionClosed.getTime() + 130 * oneDay;

  var dueDate = new Date(dueMillis);

  event.value = util.printd("m/dd/yyyy",dueDate);

}

else

  event.value = "NA";

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
May 23, 2016

As mentioned, this would require quite a complex script to be developed. If you're interested, I've already developed a script that allows you to set up exactly this kind of calculation, including the option to ignore weekends and holidays (you can specify the list of holidays for your country). It can be purchased from here: Custom-made Adobe Scripts: Acrobat -- Apply Automatic Date Calculation

Inspiring
May 23, 2016

Do we have to account for holidays or feast days?

If so  this makes the script far more complicated since these special days might not be fixed from year to year.

May 24, 2016

No need to account for holidays.