Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Calculating Dates

Guest
May 23, 2016 May 23, 2016

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";

TOPICS
Acrobat SDK and JavaScript , Windows
337
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 23, 2016 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 24, 2016 May 24, 2016
LATEST

No need to account for holidays.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2016 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines