PDF Editing Issues

How to Create a Dynamic Year Range in an Acrobat PDF Form

Anum MushtaqAnum Mushtaq Nov 10, 2026 869 views

Question details

The user needs a PDF form to automatically generate and display a year range calculated from the year the application is completed, rather than using a static date.

How to Create a Dynamic Year Range in a PDF Form
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating advanced PDF forms that require automatic date or year range calculations based on the specific time of form filling.
Observed behavior
Standard date formats in PDF form fields do not support calculated offsets or dynamic year ranges, requiring a script-based workaround.
Before you start

Ensure you have access to a PDF editor that supports JavaScript form properties, such as Adobe Acrobat Pro or WPS PDF, and familiarize yourself with basic text field settings.

Solution 1Recommended

Use Custom Calculation Scripts for Automatic Generation

Since standard date formats cannot calculate dynamic offsets, use a custom JavaScript in the calculation tab to automatically pull the completion year and build the range string.

PDF standard date properties restrict fields to simple calendar dates. To compute a dynamic year range (e.g., 2023-2024), you must bypass the standard date formats entirely and apply a custom calculation script to a standard text field.

1
Access Field Properties

Open your PDF form in edit mode and double-click the target text field where you want the year range to appear to open its Properties dialog.

2
Remove Default Date Formatting

Navigate to the 'Format' tab and ensure the format category is set to 'None' rather than 'Date'.

3
Apply Calculation Script

Switch to the 'Calculate' tab and select 'Custom calculation script'. Click the 'Edit' button to open the JavaScript editor.

4
Enter the JavaScript Code

Enter a script that retrieves the current year, adds your offset, and assigns it to the field value. For example: var currentYear = new Date().getFullYear(); event.value = currentYear + ' - ' + (currentYear + 1);

Use Custom Calculation Scripts for Automatic Generation
Script Execution: Make sure to test the form outside of editing mode to ensure the calculation script executes correctly when a user opens or interacts with the document.
Advanced PDF Form Editor

Use WPS PDF to Edit and Manage Interactive Forms

WPS Office provides a comprehensive PDF editor that allows you to easily create, fill, and manage interactive PDF forms. Its intuitive interface simplifies advanced document formatting for all users.

  1. 1. Open Your PDF: Launch WPS Office and open the PDF form you need to edit.
  2. 2. Access Form Tools: Navigate to the 'Form' tab located on the top ribbon to access interactive form tools.
  3. 3. Add a Text Field: Click to insert a 'Text Field' into your document and double-click it to configure its properties and formatting.
  4. 4. Save and Share: Once your dynamic fields are set up, save the customized PDF form and share it with your users.
Easily create and edit interactive PDF form fieldsHighly compatible with Microsoft Office and Adobe Acrobat document formatsLightweight, fast, and available across multiple devicesFree to use for everyday PDF reading and filling tasks
microsoft office alternative - wps office

Frequently Asked Questions

Can I use standard date formats for year ranges in PDF forms?

No, standard PDF date formats are designed strictly to select and display a single calendar date. To compute and display year ranges, you must use text fields with custom scripts.

What JavaScript code gets the current year in a PDF?

You can use 'new Date().getFullYear();' within a custom calculation script to retrieve the current four-digit year from the user's system.

Why isn't my PDF calculation script updating automatically?

Calculation scripts trigger based on the document's field calculation order or when other fields are modified. Check your form properties to ensure the field calculation order is sequenced correctly.