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

Need Help Creating Timesheet in Adobe Acrobat

New Here ,
Mar 16, 2021 Mar 16, 2021

Copy link to clipboard

Copied

Hi all, 

I am new to using adobe acrobat and am very confused. I want to convert and old timesheet that had been made in excel into a fillible form on adobe acrobat. I am having trouble with the calulations for the total hours (military time). In excel the sheet calculates using the formula under the hours cell is  =MOD(G8-F8,1) where G8 is time out and F8 is time in. How would I do this in adobe so that I get the same result?

All I want is a simple time in, time out, and total hours, and I want to make sure it can calculate if the times go beyond midnight. 

I would appreciate as much info as I can get, thanks!

TOPICS
How to

Views

2.0K

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

New Here , Mar 16, 2021 Mar 16, 2021

I actually found the answer in a different post! Thanks to try67, kudos to you!! The only difference is that in my script I had "TimeInRow1" instead of "Time 3.1" and "TimeOutRow1" for "Time 4.1". Hope this is helpful for anyone that needs!!

var start = this.getField("Time 3.1").valueAsString;
var finish = this.getField("Time 4.1").valueAsString;

if (start=="" || finish=="") event.value = "";
else {
	var startArr = start.split(":") ;
	var finishArr = finish.split(":") ;

	var hourDiff = finishAr
...

Votes

Translate

Translate
Community Expert ,
Mar 16, 2021 Mar 16, 2021

Copy link to clipboard

Copied

I've moved this from the Using the Community forum (which is the forum for issues using the forums) to the Acrobat forum so that proper help can be offered.

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 ,
Mar 16, 2021 Mar 16, 2021

Copy link to clipboard

Copied

I actually found the answer in a different post! Thanks to try67, kudos to you!! The only difference is that in my script I had "TimeInRow1" instead of "Time 3.1" and "TimeOutRow1" for "Time 4.1". Hope this is helpful for anyone that needs!!

var start = this.getField("Time 3.1").valueAsString;
var finish = this.getField("Time 4.1").valueAsString;

if (start=="" || finish=="") event.value = "";
else {
	var startArr = start.split(":") ;
	var finishArr = finish.split(":") ;

	var hourDiff = finishArr[0] - startArr[0];
	var minDiff = Math.floor(((finishArr[1] - startArr[1]) / 60)*100);
	if (minDiff<0) {hourDiff--; minDiff += 100;}
	if (hourDiff<0) hourDiff+=24;
	if (minDiff.toString().length == 1) minDiff = '0' + minDiff;
	event.value = hourDiff + "." + minDiff;
}

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
Enthusiast ,
Mar 16, 2021 Mar 16, 2021

Copy link to clipboard

Copied

Just a tip, not sure what format you need, but for example lets say time diff is 7h and 30min,  the above code will give you 7.50 instead of 7:30.

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 ,
Jun 13, 2022 Jun 13, 2022

Copy link to clipboard

Copied

How to solve this problem? Thanks @Asim123 

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 ,
Jun 13, 2022 Jun 13, 2022

Copy link to clipboard

Copied

Change these lines:

 

if (minDiff.toString().length == 1) minDiff = '0' + minDiff;
event.value = hourDiff + "." + minDiff;

 

To:

 

event.value = (hourDiff + minDiff/60).toFixed(2);

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 ,
Jun 13, 2022 Jun 13, 2022

Copy link to clipboard

Copied

This line is incorrect:

if (minDiff<0) {hourDiff--; minDiff += 100;}

It needs to be:

if (minDiff<0) {hourDiff--; minDiff += 60;}

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 ,
Sep 26, 2023 Sep 26, 2023

Copy link to clipboard

Copied

What column formats did you use?

Hours, numbers, text only..?

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 ,
Mar 11, 2024 Mar 11, 2024

Copy link to clipboard

Copied

I am completly out of my depth here - does anyone know what the code would be to auto calculate the below?

Fileds are example: Monday start, Monday end, Monday break, Monday total

Lisa36017076y3ni_0-1710223222788.png

 

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 ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

LATEST

 

To achieve the same calculation functionality in Adobe Acrobat as in Excel for your timesheet, you can use JavaScript to perform the calculations. Here's how you can set it up:

  1. Open your PDF form in Adobe Acrobat.
  2. Go to the "Prepare Form" tool.
  3. Select the "Text Field" tool and create fields for Time In, Time Out, and Total Hours.
  4. Right-click on the Total Hours field and select "Properties."
  5. Go to the "Calculate" tab.
  6. Choose "Custom calculation script" and click on the "Edit" button.
  7. In the JavaScript editor, enter the following code:

 

javascriptCopy code
// Calculate total hours var timeIn = getField("TimeIn").valueAsString; var timeOut = getField("TimeOut").valueAsString; if (timeIn && timeOut) { var timeInArray = timeIn.split(":"); var timeOutArray = timeOut.split(":"); var hoursIn = parseFloat(timeInArray[0]); var minutesIn = parseFloat(timeInArray[1]); var hoursOut = parseFloat(timeOutArray[0]); var minutesOut = parseFloat(timeOutArray[1]); if (hoursOut < hoursIn || (hoursOut == hoursIn && minutesOut < minutesIn)) { hoursOut += 24; } var totalHours = (hoursOut - hoursIn) + (minutesOut - minutesIn) / 60; event.value = totalHours.toFixed(2); // Display total hours with two decimal places } else { event.value = ""; // If either Time In or Time Out is empty, clear Total Hours field }
 
  1. Click "OK" to close the JavaScript editor and then "Close" to exit the field properties dialog.
  2. Repeat steps 4-8 for the Time In and Time Out fields if you want them to display a specific format.

This JavaScript code calculates the total hours based on the Time In and Time Out values, taking into account if the times go beyond midnight. Make sure to adjust field names in the script (e.g., "TimeIn" and "TimeOut") to match the names of your actual form fields.

Once you've set up the script, your PDF form should be able to calculate the total hours automatically as you input Time In and Time Out values.

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