PDF Editing Issues

Combine and Format Two Date Fields in an Adobe Acrobat Form

Olivia MillerOlivia Miller Nov 25, 2026 868 views

Question details

Combine two dates in an Adobe Acrobat form into a sentence with weekdays, month names, and ordinal days.

Combine and Format Two Date Fields in an Adobe Acrobat Form
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A form has two source date fields and a calculated field that should display both dates as a sentence.
Observed behavior
The desired output is a sentence such as “Friday, June 2nd, and Saturday, June 3rd.”
Before you start

Open the PDF in Adobe Acrobat and check that you can edit its form fields in Prepare a form. Confirm the field names are day1, day2, and days, or substitute your own names in the scripts.

Solution 1Recommended

Format the source dates and combine their values

Use validation scripts to turn entered dates into formatted text, then join the two field values in a calculated field.

This method stores the formatted dates as text in the source fields. Enter dates as M/D/YYYY, and replace the entire field value when changing a date.

The calculated-field variables already contain values, not field objects, so do not append .value to date1 or date2.

1
Open the form editor

In Acrobat, open the PDF and choose All tools > Prepare a form. Open Properties for the day1 field.

2
Set the source field format

On the Format tab, select None. This lets the validation script store the formatted sentence fragment as text instead of applying a separate date display format.

3
Add date validation

On the Validate tab, select Run custom validation script, click Edit, and paste: if (event.value !== '') { var m = /^\s*(\d{1,2})\/(\d{1,2})\/(\d{4})\s*$/.exec(event.value); if (!m) { app.alert('Enter a date as M/D/YYYY.'); event.rc = false; } else { var month = Number(m[1]), day = Number(m[2]), year = Number(m[3]); var date = new Date(year, month - 1, day); if (year < 100 || date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) { app.alert('Enter a valid date as M/D/YYYY.'); event.rc = false; } else { var weekdays = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; var months = ['January','February','March','April','May','June','July','August','September','October','November','December']; var suffix = (day % 100 >= 11 && day % 100 <= 13) ? 'th' : ({1:'st',2:'nd',3:'rd'}[day % 10] || 'th'); event.value = weekdays[date.getDay()] + ', ' + months[month - 1] + ' ' + day + suffix; } } }

4
Configure the second date

Open Properties for day2, select None on the Format tab, and add the same custom validation script on the Validate tab.

5
Combine the fields

Open Properties for days. On the Format tab, select None. On the Calculate tab, select Custom calculation script, click Edit, and enter: var date1 = this.getField('day1').valueAsString; var date2 = this.getField('day2').valueAsString; event.value = date1 && date2 ? date1 + ', and ' + date2 : date1 || date2;

6
Test the result

Close form editing or use Preview, then enter 6/2/2023 in day1 and 6/3/2023 in day2. Commit each entry and check that days displays “Friday, June 2nd, and Saturday, June 3rd.”

Format the source dates and combine their values
JavaScript support: Test the form in Acrobat or another PDF viewer that supports Acrobat form JavaScript. Some viewers may not run validation or calculation scripts.
Free Microsoft Office alternative

Work with PDF forms and Office files in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface for working with PDFs and Microsoft Office files. It can help you move everyday documents into one workspace, but it does not replace the Acrobat JavaScript setup described above.

Open and work with PDF documents alongside other filesCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar editing interface for a smoother move from Microsoft OfficeFree, lightweight suite for everyday document work
QA img-9

Frequently Asked Questions

Why does adding .value to date1 produce an incorrect result?

If date1 was assigned from this.getField('day1').value or .valueAsString, it already holds a value rather than a field object. Use date1 directly in the calculation.

How do I change a date after it has been formatted?

Select the entire value in the source field and replace it with a new date in M/D/YYYY format. Commit the entry to run the validation script again.

What happens if only one date is entered?

The calculation script displays the one available date. Once both fields contain values, it joins them with a comma and “and.”

Why does the form work in Acrobat but not in another PDF viewer?

The other viewer may not support Acrobat form validation or calculation JavaScript. Open and test the form in Acrobat, and check the viewer's JavaScript support before distributing it.