PDF Editing Issues

Calculate a PDF Form Date 1,096 Days After the Later Date

Elise WilliamsElise Williams Nov 19, 2026 868 views

Question details

Calculate Date3 as 1,096 days after the later of Date1 and Date2 in a PDF form.

Calculate a PDF Form Date 1,096 Days After the Later Date
Product
Adobe Acrobat PDF forms
Device & OS
not provided
Scenario
A form needs to compare two entered dates and automatically populate a third date.
Observed behavior
Date3 should display the date 1,096 days after the later input date.
Before you start

Open the form in a PDF editor that supports Acrobat form JavaScript, such as Adobe Acrobat Pro. Confirm that the form fields are named Date1, Date2, and Date3 and that the input dates use the mm/dd/yyyy format.

Solution 1Recommended

Add a custom calculation script to Date3 in Adobe Acrobat

Use this method to calculate Date3 automatically when both input dates are present.

The script compares the two dates, adds 1,096 calendar days to the later one, and formats the result as mm/dd/yyyy. It leaves Date3 blank if an input is missing or cannot be parsed.

1
Open the form editor

Open the PDF in Adobe Acrobat Pro and select All tools > Prepare a form. Create or confirm the text fields Date1, Date2, and Date3.

2
Open the calculation settings

Double-click Date3 to open its properties. On the Calculate tab, select Custom calculation script and click Edit.

3
Enter the script

In the JavaScript editor, enter the following script and confirm the dialog: var s1 = this.getField("Date1").valueAsString; var s2 = this.getField("Date2").valueAsString; try { var d1 = s1 ? util.scand("mm/dd/yyyy", s1) : null; var d2 = s2 ? util.scand("mm/dd/yyyy", s2) : null; if (!d1 || !d2 || isNaN(d1.getTime()) || isNaN(d2.getTime())) { event.value = ""; } else { var later = d1 > d2 ? d1 : d2; later.setDate(later.getDate() + 1096); event.value = util.printd("mm/dd/yyyy", later); } } catch (e) { event.value = ""; }

4
Save and test the form

Save the PDF, exit form editing, and enter dates in Date1 and Date2. Check that Date3 updates when either input changes and remains blank when either input is empty.

Add a custom calculation script to Date3 in Adobe Acrobat
Viewer support matters: The calculation requires a PDF viewer that supports Acrobat form JavaScript. Some browser and mobile PDF viewers may not run the script.
Free Microsoft Office alternative

Calculate dates in WPS Spreadsheets

WPS Office is a free, lightweight alternative with a familiar interface and compatible Office formats for an easy transition. WPS Spreadsheets can calculate the same date in a worksheet, although this does not add an Acrobat JavaScript calculation to a PDF form.

Compare two worksheet dates with a MAX formula and add 1,096 days.Open and edit Microsoft Excel XLSX spreadsheets.Work in a familiar spreadsheet interface with a free, lightweight office suite.
QA img-9

Frequently Asked Questions

What happens if one date field is empty?

The script leaves Date3 blank until both Date1 and Date2 contain dates that can be parsed.

Where do I put the calculation script in Acrobat?

Select All tools > Prepare a form, double-click Date3, and open Calculate > Custom calculation script > Edit.

Why does the calculation work in Acrobat but not in my browser?

Some browser PDF viewers do not support Acrobat form JavaScript. Open the saved form in a viewer that supports it and test the fields again.

Can I calculate the same result in a spreadsheet?

Yes. If A1 and B1 contain valid spreadsheet dates, enter =MAX(A1,B1)+1096 in another cell and format that cell as a date. This calculates a worksheet result, not a PDF form field.