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

Calculate business days between two dates

New Here ,
May 10, 2017 May 10, 2017

Good evening, I would need a big help, in a PDF form I need to visualize in a field that we call "TotDayi" a number obtained from the interval of two date fields, which we call "DateStart" and "DateEnd", as title The days are workable and can be developed in a working week of 5 days or 6 days (Saturday included), all this to calculate the days of actual work are also considered festivities including the patron saint and easter (or rather The pasquetta as the easter always falls on Sunday), in order to return the actual days between two dates I used this script:

Code:

//console.show();
//console.clear();


var strStart = this.getField("dalgg").value;
var strEnd = this.getField("Algg").value;
if(strStart.length && strEnd.length)
{
 
var dateStart = util.scand("dd/mm/yyyy",strStart);
 
var dateEnd = util.scand("dd/mm/yyyy",strEnd);
 
var diff = dateEnd.getTime() - dateStart.getTime();
 
var oneDay = 24 * 60 * 60 * 1000;
 
var days = Math.floor(diff/oneDay);
 
event.value = 1+days;
}
else
 
event.value = 0;

Where 1 + days returns 1 if the working day is between the same date (start date today, end date today), vice versa if I did not add that 1 returned me 0.

Could you give me a helping hand please? I do not know how to do it, I am very scarce, how can I implement this code to determine the sabbaticals on Sundays easter and eclectic festivals so that they are taken away by the number of days that would actually work and could choose whether the calculation of days ago Done on 5 working days or on 6 if we include Saturday?

Thanks to everyone in any case

TOPICS
Acrobat SDK and JavaScript
772
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 10, 2017 May 10, 2017
LATEST

I've developed a script that does something quite similar to that, including the option to ignore weekends and a custom-defined list of holidays: Custom-made Adobe Scripts: Acrobat -- Apply Automatic Date Calculation

It should not be too difficult to adjust it to your needs. You can contact me privately (try6767 at gmail.com) to discuss it further.

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