How to Automatically Share a Year Between PDF Date Fields
Question details
The user wants to automatically populate a separate year field based on the date selected in a day-and-month field within a fillable PDF form.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating interactive PDF forms where users select a date, and the form needs to split the day/month and the year into two separate text fields.
- Observed behavior
- When a PDF date field is formatted to display only the day and month, the calendar picker drops the year data entirely. Consequently, the year cannot be retrieved or copied to the secondary year field.
Ensure you have access to the PDF form editing tools and have basic familiarity with JavaScript console commands or field calculation scripts, as date formatting is script-driven.
Include Year in Source Format and Use a Calculation Script
Capture the full date in the primary field so the year is retained, then use a script to split the data and push the year to the secondary field.
A field formatted only for day and month will not retain the year selected in the date picker. To fix this, you must temporarily include the year in the source field's formatting, then use custom JavaScript to manipulate how it is displayed and shared.
Change the formatting of your first date field to include the year, using a format such as 'dd mmmm yyyy'. This ensures the calendar pop-up retrieves the full date data.
In your PDF editor's form tools, open the JavaScript console window to apply custom actions to the field.
Execute a script that formats the date, splits the value, and passes the year to your target field. For example: this.getField('DayMonthDateField').setAction('Format', "AFDate_FormatEx('dd mmmm yy'); var bits = event.value.split(' '); this.getField('YearDateField').value = bits.pop(); event.value = bits.join(' ');");
Layer Two Form Fields to Isolate Date Components
Use a fully formatted date field hidden under a partially covering field to simulate isolated date components without complex console scripting.
Easily Create and Manage Interactive PDF Forms with WPS Office
WPS PDF provides intuitive form-building tools, allowing you to insert text fields, date pickers, and interactive elements with ease. Build professional fillable PDFs and manage field properties seamlessly.
- 1. Open your PDF document: Launch WPS Office and open the PDF file you wish to turn into an interactive form.
- 2. Access Form tools: Navigate to the 'Form' tab in the top menu ribbon to access all interactive components.
- 3. Insert Date and Text Fields: Click 'Date Field' or 'Text Field' and draw the field onto your document. Double-click to configure formats, calculations, and properties.

Frequently Asked Questions
Why does a day-and-month PDF field drop the year data?
When a date field is formatted to display only the day and month, the underlying value saved in the form field is just the formatted text. The year data selected from the calendar picker is discarded and cannot be referenced or copied by other fields.
Does WPS PDF support JavaScript for form fields?
Yes, WPS PDF supports standard JavaScript functions for form field calculations, custom formatting, and data validation, ensuring interactive PDF forms function properly.
How do I hide the year in one field while sharing it to another?
You can capture the full date (including the year) using a custom script, extract the year to push into the secondary field using split/pop commands, and then automatically reformat the original field's displayed value to hide the year.
Can I format a PDF date field to show the month first?
Yes, you can customize the date format by opening the field properties and setting the format string to 'mm/dd/yyyy', 'mmmm dd', or any pattern that matches your regional preference.




