PDF Editing Issues

How to Automatically Share a Year Between PDF Date Fields

Amos GikundaAmos Gikunda Nov 2, 2026 869 views

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.

How to Automatically Share a Year Between PDF Date Fields
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.
Before you start

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.

Solution 1Recommended

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.

1
Include the year in the source field format

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.

2
Open the JavaScript console

In your PDF editor's form tools, open the JavaScript console window to apply custom actions to the field.

3
Run a formatting and split script

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(' ');");

Script Logic Explained: This script pulls the full date string, uses the split and pop functions to remove the year portion to populate the 'YearDateField', and rejoins the remaining parts to display only the day and month in the primary field.

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. 1. Open your PDF document: Launch WPS Office and open the PDF file you wish to turn into an interactive form.
  2. 2. Access Form tools: Navigate to the 'Form' tab in the top menu ribbon to access all interactive components.
  3. 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.
Comprehensive PDF form building and field calculation tools.High format compatibility with standard Adobe Acrobat PDF forms.Lightweight, fast-loading, and user-friendly interface.Cross-platform support for Windows, Mac, iOS, and Android.
microsoft office alternative - wps office

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.