How to Compare Dates in Adobe Acrobat JavaScript Forms
Question details
The user needs to create an Adobe Acrobat JavaScript calculation to compare form input dates against a specific deadline, such as charging different fees before and after a set date.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating a dynamic PDF form with time-sensitive pricing or registration deadlines.
- Observed behavior
- The goal is to accurately parse and compare date values within an Acrobat PDF form using JavaScript to trigger dynamic field changes.
Ensure your PDF form has the necessary text fields configured for date input, and verify that you have access to the 'Prepare Form' tools to insert custom calculation scripts.
Use the Standard JavaScript Date Constructor
Create a target deadline date object by passing the year, month, and day directly into the standard JavaScript Date method.
Standard JavaScript Date constructors use a zero-based index for months. This means January is represented by 0, February by 1, and March by 2. You must account for this offset when hardcoding your deadline date in the script.
Open your PDF in Adobe Acrobat, enter the 'Prepare Form' mode, right-click the calculation field (e.g., the fee total), and select 'Properties'.
Click on the 'Calculate' tab at the top of the Properties dialog box and select the 'Custom calculation script' option.
Click 'Edit' and enter the Date constructor variable. For example, to set March 16, 2019, type: var DeadlineDate = new Date(2019, 2, 16);
Add your conditional if/else statements to compare the user's input date against DeadlineDate, and assign the appropriate fee output based on the result.

Use Acrobat's util.scand Date Parser
Parse a formatted date string directly into a JavaScript date object using Adobe's built-in util.scand utility.
Manage and Fill Interactive PDF Forms with WPS Office
If you are looking for a highly capable and user-friendly tool to handle PDF files, WPS Office provides a robust PDF editor. It easily opens, fills, and manages interactive PDF forms without requiring complex scripting.
- 1. Open your PDF: Launch WPS Office and open your interactive PDF form document.
- 2. Access PDF Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available form fields and interactive elements.
- 3. Fill and Edit: Click into the date, text, or calculation fields to input your data directly.
- 4. Save or Export: Once completed, click 'Save' or export your filled PDF form to share it securely.

Frequently Asked Questions
Why do JavaScript months start at 0 in Adobe Acrobat?
Adobe Acrobat utilizes standard JavaScript for form calculations. In JavaScript, the Date object is designed with a zero-based index for months, meaning January is 0 and December is 11, while days and years remain 1-based.
What is the difference between new Date() and util.scand() in Acrobat?
The new Date() function is a standard JavaScript method used universally across web and app development. In contrast, util.scand() is a proprietary Acrobat method specifically designed to parse custom formatted date strings (e.g., "mm/dd/yyyy") into JavaScript Date objects.
How do I trigger the JavaScript date calculation in my PDF form?
You can trigger the calculation automatically by placing the script in the field that displays the result. Go to the field's Properties > Calculate tab, and select 'Custom calculation script'. It will execute whenever the linked date field values change.




