• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Time calculations in adobe acrobat pro dc.

Community Beginner ,
Nov 13, 2016 Nov 13, 2016

Copy link to clipboard

Copied

I am have the hardest time figuring this out.  Two whole days.  I am trying to configure time and setting it in regular time. 

So what I need is as follows

Date                      Time in               time out       Total Time

September 1          8:00am                2:30pm         6:30 and or 6.5

But every time I put in any calculations it does not come out correct.

Please help

I can actually send you the PDF to make this seem easier.

TOPICS
PDF forms

Views

11.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 15, 2016 Nov 15, 2016

I believe the issue is about computing the elapsed time or the time worked.

The OP's use of the simplified field notation does not work because there are non-numeric characters in the values being processed. In order for values to be processed in the Simplified Field Notation they must consist of an option sign ( + or -) numeric digits and optional decimal point and more digits. The presence of the ":" makes the value a string and dropped from the calculation. Only Custom JavaScript code can proc

...

Votes

Translate

Translate
LEGEND ,
Nov 14, 2016 Nov 14, 2016

Copy link to clipboard

Copied

Please let us know script you currently have to calculate, and then we can hopefully help you understand how to fix it. Also please give the formats of the input and output fields, and where you set the script. Also, what do you expect your users to ACTUALLY TYPE in the field?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 14, 2016 Nov 14, 2016

Copy link to clipboard

Copied

I am subtracting both times (Feild13-Feild1)

The formats are HH:MM:tt

I expect my employees to type in 8:00 am(start time) and 5:00 pm (end time)

thank you for the help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

Test Screen, can I send you my document by email so that we can discuss exactly what I need.  I am trying alot of the suggestions but it is not working the way I need.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 14, 2016 Nov 14, 2016

Copy link to clipboard

Copied

Do you ever expect the time entries to include 1:00am to 3:00am?

If so on certain date you will need to adjust for time changes brought about by Day Light Savings Time.

Will the elapsed time value ever be negative?

What results are you getting?

Have you looked at the Acrobat JavaScript API Reference, the Mozilla JavaScript Reference, and Thom Parkers series on date and time calculations at Acrobat Users?

This calculation can only be done using Custom JavaScirpting.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 14, 2016 Nov 14, 2016

Copy link to clipboard

Copied

I expect my employees to type in 8:00 am(start time) and 5:00 pm (end time)

It is easier to get a correct preformatted input via a listbox or a JavaScript drop down menu.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 14, 2016 Nov 14, 2016

Copy link to clipboard

Copied

I have no clue of how to create that.  Would you mind helping?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

Creating a listbox is well explained in Acrobat's Help.

For a JavaScript drop down you can start here (clic the "Ressources" links): create drop down menu (PDF Forms)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

I believe the issue is about computing the elapsed time or the time worked.

The OP's use of the simplified field notation does not work because there are non-numeric characters in the values being processed. In order for values to be processed in the Simplified Field Notation they must consist of an option sign ( + or -) numeric digits and optional decimal point and more digits. The presence of the ":" makes the value a string and dropped from the calculation. Only Custom JavaScript code can process this type of data.

The approach for the coding is converting the time into the JavaScript date object, This object contains or can compute various information about the date. It also has assigns a unique value to every millisecond. This number can be used to compute the difference between to date time combinations or compute a future date time combination.

There is a limited second way to computer time differences by parsing the time strings into hours and minutes and then doing the needed math. This method is very limited and cannot be used if the time interval includes the period of time when Day Light Savings Time change occurs or one is computing the time difference involving 2 different time zones.

See Thom Parker's Working with date and time in Acrobat JavaScript (Part 1 of 3), Working with date and time in Acrobat JavaScript (part 2 of 3) , Working with date and time in Acrobat JavaScript (part 3 of 3)

Adobe Acrobat JavaScript API Reference util.scand

Mozilla Development Network JavaScript Reference Date object

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 29, 2020 Nov 29, 2020

Copy link to clipboard

Copied

Hello, I am getting negative numbers with this calculation.

I.e. start 22:45 End 03:15 result is -20:30 instead 04:30 I am trying to do flight time calculation departure time is 22:45 arrival time 03:15 next day, I need total hours flown

 

var hrsStart = parseInt(this.getField("time2_1").value.split(":")[0]); var minStart = parseInt(this.getField("time2_1").value.split(":")[1]); var hrsEnd = parseInt(this.getField("time4_1").value.split(":")[0]); var minEnd = parseInt(this.getField("time4_1").value.split(":")[1]); if (minStart > minEnd) { var minRez = 60 + minEnd - minStart; var hrsRez = hrsEnd - 1 - hrsStart; } else { var minRez = minEnd - minStart; var hrsRez = hrsEnd - hrsStart; } this.getField("flight1").value = hrsRez + ":" + minRez; if(flight1 < 0) {// Shift 24 hours flight1 += 24; }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2020 Nov 30, 2020

Copy link to clipboard

Copied

LATEST

The last line of the code does nothing, and is also not set up correctly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

Sorry no I can't do private consultations. But if you can share it publicly someone may have time to take a look.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

See  Date Time Calculation for a working example of your problem. Be sure to try the date Summer Time, Day Light Savings Time, or War Time begins and use the hours of around 2:00 am.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2018 Jun 14, 2018

Copy link to clipboard

Copied

Good Evening gkaiseril,

If I have multiple "Total Time Worked" field how can I tally and them together? Also, how do I keep the same formatting?

Thank you

Format.JPG

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2018 Jun 14, 2018

Copy link to clipboard

Copied

I figured it out!  just copy the "custom format script" over and it fixed the issue. Thank you for providing the example form.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

How would I make a calculation if i need the regular hours and overtime hours and total hours but i don't have time in and time out for each day, i only have the total number of hours per day.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

Calculation Snipbit.JPG

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

What's the formula for regular time v. overtime, then?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

Is overtimeHours the number of hours over 8/day, or something like that?

The first thing I'd do is rename your fields to something more script friendly.

Such as, "hours.Sunday", "hours.Monday", etc. 

 

Now, you can write a loop that will get the hours for each day and then use some criteria to determine how many of that days hours are regular and overtime. 

 

 

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines