URGENT: Calculating Elapsed Time Over Multiple Days

U

UGD Studios

I hope you can help me.

I have very little knowledge of XPath code or JScript Code and I am getting
quite frustrated making my form functional. I have an invoice that I have
created that tracks not only expenses but my hours worked (i am an
independent contractor). I have seen the sample time cards that come with
InfoPath, but I can't seem to find the code that makes them work (perhaps it
has been hidden by the software developers for just this reason).

Anyways, I recently read a thread on the MSDN InfoPath Team Blog called
'Calculating Elapsed Time...without code' at
http://blogs.msdn.com/infopath/archive/2007/02/21/calculating-elapsed-time-without-code.aspx

I tried the examples applied to my form and everything worked fine except
for one major problem. If the time period extends past midnight, it returns
a negative integer for the total time. Ex: If I clock in at 4 PM and clock
out at 2AM, I have worked for 10.00 hours, but I receive -14.00 hours in the
total hours.

So I left a comment on the thread for the author, Scott Heim, asking for any
advice. He responded that it would be easier to do a calculation like that
with custom code.

After a few Google searches, I came across your thread 'Calculating Time
Differences With Custom JScript Code'. I read through the article and tried
the example and had the same results.

How can I get this to work?? HELP:???

Now, I read in the notes of the .js file I downloaded that the 'function
calcTimeInMinutes' function 'Calculates the elapsed time given a start time
and end time in the "hh:mm" time format. Since date calculations are not
being done, the date has been set to January 1, 1970.'

Does that mean that if I were to enter the date of when I clocked in instead
of January 1, 1970, it would work? If so, how do I do that? The code for
that section wasn't exactly 'straight-forward' to someone unfamilliar with
the language. Also, is there just a way to extract that data from the date
field that I have in the repeating table so it figures it out automatically?
That would be the best for my application.

I appreciate any help you can give me. Also if you have any suggestions on
reading material or books I should get to learn these code languages.

Thank you so much.

~Geoff
 
S

S.Y.M. Wong-A-Ton

The article was written specifically to calculate time differences only. I
wrote a few articles for calculating date/time differences in InfoPath using
VBScript or JScript, but unfortunately, I'm unable to write articles for all
possible scenarios, which is why I restrict my articles to the most often
requested solutions. VBScript seemed to be a popular request at the time, so
I wrote the solution you require in VBScript. It is described in this
article:
http://enterprise-solutions.swits.n...fference-calculations-vbscript&c=infopath2003

And yes, you do need knowledge of either JScript or VBScript to be able to
work through these articles. A good resource for these is either the
scripting site of Microsoft (http://www.microsoft.com/scripting) or W3Schools
(http://www.w3schools.com).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top