Skip to main content
Participant
August 15, 2023
Question

Simple time addition with result more than 24 hours

  • August 15, 2023
  • 2 replies
  • 880 views

Dear Community,

 

I am new to pdf- forms, new to Acrobat Pro 2020 and new to JavaScript.

I created a form (design in Word an Excel, saved as pdf) and created a form with my Adobe Acrobat Pro 2020. There are some text-fields with format "number" and some with format "time" (Category "Time" and format "HH:MM").

While the calculation (sum) with the numbers is working, the calculation (sum) with time isn´t.

I created two fields with time-format and a third field with time-format. I choosed within the properties the tab "Calculate" and used "Value is the sum (+) of the following fields". I choosed the correct fields, but unfortunately I get a warning "The value entered does not match the format of the field [ TotalTimeSum ]".

I tried to recreate the fields. I copied the first field, wich I formated with the format "HH:MM" but nothing works without the same error.

 

1. What is / are my mistake/s with calculating time?

2. Is it possible to calculate without JavaScript / only with the included methods?

3. Is it possible to calculate the total time (not related to days; eg. 16:00 + 16:00 = 32:00 instead of 1 day and 8:00 hours)?

 

I hope there is a simple solution for me.

 

Thanks in advance for your help.

 

Best Regards from Germany

 

Daniel

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
August 15, 2023

Re #3. If you want to do it like that you can't use the Time format, since "32:00" is not a valid time. You need to write your own custom calculation script to add up the times in the first two fields, and then output the result in the desired format.

Bernd Alheit
Community Expert
Community Expert
August 15, 2023

2. No

Participant
August 15, 2023

Thanks Bernd for the quick reply.

Is there a simple way or a webpage where I can learn JavaScript or copy-paste some code related to my question above? I couldn´t find anything with the search-engine of my choice.

I can´t be the first one with this problem "calculating with times"?!

Thom Parker
Community Expert
Community Expert
August 15, 2023

Date and time calculations are very different from regular number calculations, because date/time is a different kind of thing. 

This article explains it:

https://www.pdfscripting.com/public/Date-and-Time-Handling.cfm

 

You'll find some more detailed information and sample scripts here:

https://acrobatusers.com/tutorials/date_time_part1/

https://acrobatusers.com/tutorials/date_time_part2/

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often