PDF Editing Issues

Calculate Hours and Minutes From PDF Drop-Down Lists in Acrobat

Huma Ashraf ChHuma Ashraf Ch Nov 18, 2026 868 views

Question details

Calculate a total duration from values selected in drop-down fields on a fillable PDF timesheet.

Calculate Hours and Minutes From PDF Drop-Down Lists in Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A weekly timesheet uses drop-down fields to select daily durations and needs to display their total in hours and minutes.
Observed behavior
The desired result is a total that adds the selected durations and displays them in hours:minutes format.
Before you start

Open the fillable timesheet in Acrobat and note the exact names and export values of the duration drop-down fields. The example below expects duration values such as 1:30, not clock times such as 9:30 AM.

Solution 1Recommended

Add a custom calculation script to the total field in Acrobat

Use this method to total drop-down durations in a fillable PDF and display the result as hours and minutes.

The script converts each selected duration to minutes, adds the minutes, and converts the total back to hours:minutes. It supports totals greater than 24 hours.

1
Check the drop-down values

Open All tools > Prepare a form, then open each drop-down field's Properties and check the Options tab. Use export values in hours:minutes format, such as 0:30 or 2:15, and use a blank export value for an unselected option.

2
Open the total field calculation

In Prepare a form, open the Properties of the text field that will display the total. On the Calculate tab, select Custom calculation script and click Edit.

3
Enter and adapt the script

Paste the script below and replace Day1, Day2, and Day3 with the exact names of your drop-down fields. Add or remove names as needed; do not include the total field itself. var fields = ["Day1", "Day2", "Day3"]; var total = 0; var invalid = false; for (var i = 0; i < fields.length; i++) { var f = this.getField(fields[i]); if (!f) { invalid = true; break; } var raw = f.valueAsString; if (raw === "") continue; var match = /^(\d+):(\d{2})$/.exec(raw); if (!match || Number(match[2]) > 59) { invalid = true; break; } total += Number(match[1]) * 60 + Number(match[2]); } if (invalid) { event.value = "Invalid duration"; } else { var hours = Math.floor(total / 60); var minutes = total % 60; event.value = hours + ":" + (minutes < 10 ? "0" : "") + minutes; }

4
Save and test the form

Set the total field's Format to None, close its Properties, and save the PDF. Select values such as 1:30 and 2:45 in the drop-downs; the total should show 4:15.

Add a custom calculation script to the total field in Acrobat
PDF viewer support: The calculation depends on Acrobat JavaScript. Test the saved form in Acrobat or Acrobat Reader with JavaScript enabled; some other PDF viewers may not run the script.
Free Microsoft Office alternative

Track timesheet hours in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface and support for common Microsoft Office formats, making it easy to move existing timesheets into WPS Spreadsheets. It does not replace Acrobat's custom PDF form calculation script.

Create and calculate timesheets in WPS SpreadsheetsOpen and edit Microsoft Excel XLSX filesWork with Word DOCX and PowerPoint PPTX formatsUse a familiar interface for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Why does the total field show “Invalid duration”?

In Prepare a form, check that every field name in the script matches an existing drop-down. Then check each drop-down's Properties > Options: nonblank export values must use hours:minutes format, with two minute digits between 00 and 59.

Can the total exceed 24 hours?

Yes. The script treats entries as durations and displays the total hours without wrapping at 24. For example, durations totaling 27 hours and 30 minutes display as 27:30.

Will the calculation work in every PDF viewer?

No. The script requires a viewer that supports Acrobat JavaScript. Test the saved form in Acrobat or Acrobat Reader and check the JavaScript settings if the total does not update.

Can I use clock-in and clock-out times with this script?

Not directly. This script adds durations such as 7:30; calculating elapsed time from clock-in and clock-out values requires a different formula that accounts for times crossing midnight.