Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Home
- >
- Acrobat SDK
- >
- Function for timesheet calculation

Function for timesheet calculation

New Here
,

Mar 25, 2019

Copy link to clipboard

Copied

Hi Guys,

I wanted to know, Is it possible to create a Javascript Function based calculation for a timesheet that also includes amount of people working during that time period.

Example.

Start | Finish | Number of workers | Total Hours |
---|---|---|---|

Start1.0 | Finish1.0 | Workers1.0 | Totalhours1.0 |

Start1.1 | Finish1.1 | Workers1.1 | Totalhours1.1 |

Start1.2 | Finish1.1 | Workers1.2 | Totalhours1.2 |

My function would be something like CalcHours() ….. which would yield something like would calculate like this (Finish1.0 - Start1.0) * Workers1.0

your helps would be greatly appreciated.

TOPICS

Acrobat SDK and JavaScript,
Windows

Community Guidelines

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

Function for timesheet calculation

New Here
,

Mar 25, 2019

Copy link to clipboard

Copied

Hi Guys,

I wanted to know, Is it possible to create a Javascript Function based calculation for a timesheet that also includes amount of people working during that time period.

Example.

Start | Finish | Number of workers | Total Hours |
---|---|---|---|

Start1.0 | Finish1.0 | Workers1.0 | Totalhours1.0 |

Start1.1 | Finish1.1 | Workers1.1 | Totalhours1.1 |

Start1.2 | Finish1.1 | Workers1.2 | Totalhours1.2 |

My function would be something like CalcHours() ….. which would yield something like would calculate like this (Finish1.0 - Start1.0) * Workers1.0

your helps would be greatly appreciated.

TOPICS

Acrobat SDK and JavaScript,
Windows

Community Guidelines

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

joshuab76782683

Mar 25, 2019
0
/t5/acrobat-sdk/function-for-timesheet-calculation/td-p/10398411
7
Replies
7

Guide
,

Mar 26, 2019

Copy link to clipboard

Copied

Is there a particular reason to use a Javascript function for this simple calculation? Otherwise just use a Simplified Notation calculation field for your total hours field with this formula:

((finishTime - startTime)*numberOfWorkers)

Community Guidelines

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

Reply

Loading...

rayek.elfin

Mar 26, 2019
0
/t5/acrobat-sdk/function-for-timesheet-calculation/m-p/10398412#M13890
Most Valuable Participant
,

Mar 27, 2019

Copy link to clipboard

Copied

The reason is it won't work that way... Time calculations require using a script.

Community Guidelines

Reply

Loading...

try67

Mar 27, 2019
0
/t5/acrobat-sdk/function-for-timesheet-calculation/m-p/10398413#M13891
New Here
,

Mar 27, 2019

Copy link to clipboard

Copied

TRy67, do you think you would know how to solve this? you seem like you know your stuff.

Many people would appreciate it.

Community Guidelines

Reply

Loading...

joshuab76782683

Mar 27, 2019
0
/t5/acrobat-sdk/function-for-timesheet-calculation/m-p/10398414#M13892
Most Valuable Participant
,

Mar 27, 2019

Copy link to clipboard

Copied

I've developed a (paid-for) tool that allows you to set up such calculations very easily. You can find it here: Custom-made Adobe Scripts: Acrobat -- Calculate Time Differences in a Worksheet

Once you've calculated the difference between the two time fields multiplying it by the number of workers is trivial.

If you're interested I could set it all up for you (for a fee). You can contact me privately (try6767 at gmail.com) to discuss it further.

Community Guidelines

Reply

Loading...

try67

Mar 27, 2019
0
/t5/acrobat-sdk/function-for-timesheet-calculation/m-p/10398415#M13893
Guide
,

Mar 28, 2019

Copy link to clipboard

Copied

try67 wrote

The reason is it won't work that way... Time calculations require using a script.

Oops, that's true. Been a while since I worked with PDF forms.

How about this hacked together script:

// document functions

function HHMM2Min(cTime) {

var aHHMM = cTime.split(":");

var nMinutes = 0;

nMinutes = aHHMM[0] * 60;

nMinutes += Number(aHHMM[1]);

return nMinutes;

}

function Min2HHMM(nMinutes) {

return util.printf("%,001.0f:%,202.0f", Math.floor(nMinutes / 60), nMinutes % 60);

}

function calcHours(startTime,endTime,numberOfWorkers) {

var hrsStart = parseInt(startTime.split(":")[0]);

var minStart = parseInt(startTime.split(":")[1]);

var hrsEnd = parseInt(endTime.split(":")[0]);

var minEnd = parseInt(endTime.split(":")[1]);

if (minStart > minEnd) {

var minRez = 60 + minEnd - minStart;

var hrsRez = hrsEnd - 1 - hrsStart;

}

else

{

var minRez = minEnd - minStart;

var hrsRez = hrsEnd - hrsStart;

}

timeTotal = hrsRez + ":" + minRez;

sTime = timeTotal;

nSum = HHMM2Min(sTime) * numberOfWorkers;

totalHours = Min2HHMM(nSum);

return totalHours;

}

//calc field

timeStarted = this.getField('timeIn').value;

timeFinished = this.getField('timeOut').value;

workerNumber = this.getField('multiplier').value;

event.value = calcHours(timeStarted, timeFinished, workerNumber);

It does what you want, I think. I only tested with one timeIn time input field, one timeOut input field, and one multiplier (workers) field.

Community Guidelines

Reply

Loading...

rayek.elfin

Mar 28, 2019
0
/t5/acrobat-sdk/function-for-timesheet-calculation/m-p/10398416#M13894
Adobe Community Professional
,

Mar 28, 2019

Copy link to clipboard

Copied

Community Guidelines

Reply

Loading...

gkaiseril

Mar 28, 2019
0
/t5/acrobat-sdk/function-for-timesheet-calculation/m-p/10398417#M13895
rayek.elfin
LATEST

Guide
,

Mar 28, 2019

Copy link to clipboard

Copied

Yeah, I realized that this morning as well while looking at it with fresh eyes. Initially I assumed the OP wanted a simple hours a day worked, but re-reading the OP's question, he mentions a 'time period' which probably should include a full date & time object.

Back to the drawing board, if I can find the time. Or it might resolve itself if we wait long enough for all countries to abolish daylight savings

Community Guidelines

Reply

Loading...

rayek.elfin

Mar 28, 2019
0
/t5/acrobat-sdk/function-for-timesheet-calculation/m-p/10398418#M13896
Using the Community
Experience League
Terms of Use
Privacy Policy
Cookie preferences
AdChoices
Language:

- Deutsch
- English
- Español
- Français
- 日本語コミュニティ
- Português

Copyright © 2020 Adobe. All rights reserved.