PDF Editing Issues

Calculate PDF Form Dates Excluding Sundays and Holidays in Acrobat

Aamir Naveed AkramAamir Naveed Akram Nov 19, 2026 868 views

Question details

Calculate several closing dates in a PDF form from a signed date, excluding Sundays and specified holidays.

Calculate PDF Form Dates Excluding Sundays and Holidays in Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form needs date calculations similar to Excel's WORKDAY function, with Sundays and selected holidays excluded.
Observed behavior
Each closing date should count only eligible days after the signed date and appear in its designated form field.
Before you start

Open the PDF in Acrobat and check that the signed-date and closing-date fields are editable form fields. Decide how many eligible days each closing date needs and prepare a holiday list with the year included.

Solution 1Recommended

Add a Custom Calculation Script to Each Closing-Date Field

Use Acrobat JavaScript to count forward from the signed date, skipping Sundays and dates in a holiday list.

The example counts eligible days after the signed date; it does not count the signed date itself. Saturdays remain eligible unless they are listed as holidays.

The example uses SignedDate as the source field and Text2 through Text5 as the result fields. Replace the sample offsets and holiday dates with your own requirements.

1
Check the form fields

In Acrobat, open All tools > Prepare a form. Check the field names in the form editor, or rename the signed-date field to SignedDate and the four result fields to Text2, Text3, Text4, and Text5.

2
Open the calculation editor

Right-click Text2, choose Properties, open the Calculate tab, and select Custom calculation script. Click Edit to open the JavaScript editor.

3
Enter and customize the script

Paste the following script into the editor. The offsets are example numbers of eligible days, and the holiday dates are examples; update both before using the form. var offsets = { Text2: 5, Text3: 10, Text4: 15, Text5: 20 }; var holidays = ["2026-01-01", "2026-07-04", "2026-12-25"]; var source = this.getField("SignedDate"); var input = source ? source.valueAsString : ""; var match = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(input); var result = ""; if (match && offsets[event.target.name] !== undefined) { var month = Number(match[1]); var day = Number(match[2]); var year = Number(match[3]); var date = new Date(year, month - 1, day, 12, 0, 0); if (year >= 1000 && date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day) { var count = 0; while (count < offsets[event.target.name]) { date.setDate(date.getDate() + 1); var key = util.printf("%04d-%02d-%02d", date.getFullYear(), date.getMonth() + 1, date.getDate()); if (date.getDay() !== 0 && holidays.indexOf(key) === -1) { count++; } } result = util.printf("%02d/%02d/%04d", date.getMonth() + 1, date.getDate(), date.getFullYear()); } } event.value = result;

4
Apply the script to all result fields

Click OK to save the script, then open Properties > Calculate > Custom calculation script > Edit for Text3, Text4, and Text5 and paste the same script into each field. If your field names differ, update the names in the offsets object and the SignedDate reference.

5
Test the calculations

Close form editing and enter a valid date in SignedDate using MM/DD/YYYY. Check Text2 through Text5 against your expected dates, including cases that cross a Sunday or a listed holiday.

Add a Custom Calculation Script to Each Closing-Date Field
Keep holiday dates current: Add every applicable holiday as a complete YYYY-MM-DD date, including the year. An empty or invalid signed date leaves the result fields blank.
Free Microsoft Office alternative

Manage Related Date Tracking with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with documents and spreadsheets. It supports common Microsoft Office formats for easier migration, although it does not fix or replace Acrobat's custom PDF form JavaScript.

Use WPS Spreadsheets to organize signed dates and holiday listsOpen and work with Microsoft Excel XLSX filesWork in a familiar, easy-to-use Office-style interfaceUse a lightweight suite with free tools for everyday office work
microsoft office alternative - wps office

Frequently Asked Questions

Does the script exclude Saturdays?

No. The getDay() check excludes only Sundays. A Saturday is counted unless its complete date appears in the holidays array.

How do I change the number of days for a closing date?

Open the result field's Properties > Calculate > Custom calculation script > Edit and change its value in the offsets object. Update the same offsets object in each result field's script.

Why is a closing-date field blank?

Check that the source field is named SignedDate and contains a valid date in MM/DD/YYYY format. Also check that the result field name matches an entry in the offsets object and that its custom calculation script is saved.

Do I need to list holidays for every year?

Yes. The script compares complete dates in YYYY-MM-DD format, so add each holiday for every year the form is expected to cover.

Does the signed date count as the first eligible day?

No. The script advances to the next calendar day before checking whether it is eligible. The offsets therefore count eligible days after the signed date.