Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Date calculation

Community Beginner ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

I have a form in acrobat where the user can input a start and an end date which should result in a third text field displaying the days between those two dates.

My question is if there is a way to calculate the amount days between minus weekends and holidays or other specific dates.

 

Also is there a method outside of using the javascript validation as it seems impractical for this.

 

Any and all help is appreciated 🙂

TOPICS
How to, JavaScript, PDF forms

Views

30

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

It's possible, but only with JavaScript.

 

In fact, I created a (paid-for) tool that does exactly that, if you don't want to write the code yourself:

https://www.try67.com/tool/acrobat-apply-automatic-date-calculation

Likes

Translate

Translate

Report

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 Beginner ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

LATEST

I already have a working JavaScript method which only works outside of acrobat.

I also tried changing the input values to acrobat form fields and it still doesn't work.

If you have any advice on this lmk.

var StartDate = window.prompt("Start Date: ");
StartDate = parseInt(StartDate);
var EndDate = window.prompt("End Date: ");
EndDate = parseInt(EndDate);
//User input for Start & End Date as integer
//Day 1 representing the first day of the year

var DaysBetween = [];
for (var i = StartDate; i <= EndDate; i++) {
  DaysBetween.push(i);
}
//Puts all days between, including start and end day into array

var Saturday = 6;
var Sunday = 7;
//Change value to the first weekend of the year

var Holiday = [
  14,
  15,
  16
];
//Contains the date of every holiday

var Holidays = 0;
Holiday.forEach((entry) => {
  if (entry >= StartDate & entry <= EndDate) {
    Holidays++;
  }
});
//Checks each holiday if its between start and end date

console.log(Holidays);

var Saturdays = 0;
DaysBetween.forEach((entry) => {
  if (entry % Saturday == 0) {
    Saturdays++;
  }
});
console.log(Saturdays);

var Sundays = 0;
DaysBetween.forEach((entry) => {
  if (entry % Sunday == 0) {
    Sundays++;
  }
});
console.log(Sundays);

var DaysAbsent = 0;
DaysAbsent = DaysBetween.length - Holidays - Saturdays - Sundays;

console.log(DaysAbsent);

Likes

Translate

Translate

Report

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