Skip to main content
Participant
July 25, 2025
Question

I need a way to show in a field the dates between two fields.

  • July 25, 2025
  • 1 reply
  • 120 views

I am looking for a way to show in a field the number of days between two separate fields: "TodaysDate" and the exeperation terms of service "ETS" ... is there a script to use that someone can help me out?

1 reply

Legend
July 25, 2025

Hi @Whimsical_help8665,

 

Thanks for reaching out. 

 

Yes, this is possible using JavaScript in Adobe Acrobat (JavaScript for Acrobat Forms). You can write a custom script that reads two date fields and fills another field with a list of dates between them.

 

Suppose the field names are:

  • StartDate

  • EndDate

  • AllDates → this is the field where the result will be displayed.

 

 

var start = this.getField("StartDate").value;

var end = this.getField("EndDate").value;

 

if (start && end) {

    var startDate = util.scand("mm/dd/yyyy", start);

    var endDate = util.scand("mm/dd/yyyy", end);

    

    if (startDate <= endDate) {

        var dates = [];

        var currentDate = new Date(startDate);

 

        while (currentDate <= endDate) {

            dates.push(util.printd("mm/dd/yyyy", currentDate));

            currentDate.setDate(currentDate.getDate() + 1);

        }

 

        event.value = dates.join(", ");

    } else {

        event.value = "Start date must be before end date.";

    }

} else {

    event.value = "";

}

 

 

Let us know how it works. Wait for more inputs from experts.



Best regards,
Tariq | Adobe Community Team

try67
Community Expert
Community Expert
July 26, 2025

I think they want to show the number of days, not the full list.

So they can do it by replacing this line:

event.value = dates.join(", ");

With:

event.value = dates.length;