Time Calculations Using JScript

R

RichardC

Followed S.Y.M. Wong-A-Ton's instructions on how to calc. time differences.
What I need to know is how to change the scripting to allow for 2 instances
of everything. I added secondary groups and fields that mimic the first set,
having a #2 after each name. I cannot just add the JScript code again,
changing references to nodes...........or can I?

Thanks.
 
S

S.Y.M. Wong-A-Ton

Can you explain your scenario a bit more? What do you mean with 2 instances
of everything? 2 repeating tables with start time and end time? Or 2 start
times and 2 end times in 1 repeating table? It is not clear to me what you're
trying to do.
 
R

RichardC

Sorry I should have been a little more clear. I am trying to add 2 repeating
tables with start and end times. Our periods are bi-weekly and need each
week needs to be shown separately with totals. Additionally I would like to
have the daily totals add the time and subtract another field (lunchtime in
decimal format). For this field it would need to subtract all but ".5" of
it. i.e. 1 hour lunch so it would only subtract .5.

Thanks for the help and the quick repsonse. I really appreciate it. I'm no
coder. I take sample code and use logical reasoning to transform it to my
needs. A lot of times it works out, sometimes not.

Rich
 
S

S.Y.M. Wong-A-Ton

Before we dive into trying to get your scenario to work, did you already take
a look at the option without code?
http://enterprise-solutions.swits.n...=time-calculations-using-rules&c=infopath2003

Or is there a particular reason you want to use code?

I also remembered someone else posting a question once about subtracting
lunch time and managed to find the post. Take a look at what I answered there
to see if it helps you
(http://groups.google.com/group/micr...lnk=gst&q=lunch&rnum=1&hl=en#ee3ae19d9540bbf7). If it doesn't, get back to me.
 
R

RichardC

Thanks. There is no reason I wanted to use code other than to maybe pick up
on some basics. I was always under the impression that code was more
flexible. I didn't want to be handcuffed as I move my project along.

Thanks for the direction for lunch time subtraction. I am going to browse
the posts for this question too but is there a way to round entered time
values. I know I can make people enter it to the quarter hour but it would
be easier and more conducive to my users styles if they can enter actual time
and the form rounds it to the quarter hour. I have a formula that I use in
Excel (MROUND) but this is not Excel.

I appreciate your thoughts.

Rich
 
S

S.Y.M. Wong-A-Ton

I'm not a guru in Excel and couldn't find the MROUND formula you mentioned.
Did you create it yourself? You can probably use the same logic of that
formula within InfoPath to round the minutes. By the way, what do you mean
with round to the quarter hour? If a user types in 11:35, it rounds it to
11:30 or 11:45? Is that what you meant? If not, can you give me a few
examples?
 
R

RichardC

I'm no guru in Excel either. I found the function on the Internet.
Basically it takes a cell in which time is entered and gives the time back,
rounded to the nearesr quarter-hour. For example if a user enters 11:07, it
would give you back 11:00. If a user enters 11:08, it would give you back
11:15. It allows you to write a formula and it would function as a time
clock. Most of our users feel the need to enter the exact time the are in
and out. But, the accounting department need to know the time they worked to
the quarter-hour. We had a time clock at one point and could not afford the
service. So, I gathered my powers of Internet search and wrote the lengthy
formula that rounds BOTH times (in and out) separately, calculates the
difference, and returns the total (in a decimal format). None of which is
code, all formula; if's, vlookup's, lots of brackets, etc., etc. Although I
am more than confident in my powers of deduction and logical reasoning, I
have 0 powers in coding and therefore none of it is logical to me.

While I appreciate your attempts to make things more lucid, I certainly
understand that you need to make a livin and can only offer limited support
in this "free" forum. Please be mindful that I work as the sole IT support
for a small non-profit that cannot spend money to research a product that was
given to us in-kind by MS. This is just my attempt to make things easier on
employees so they can spen more time investing in our mission, thus bringing
down costs and elevating productivity.

Thank you bunches for all of your wonderful insight.
Richard
 
S

S.Y.M. Wong-A-Ton

I've studied your scenario a bit more, and while you can use rules to
re-format the time using a technique as described in this article
http://enterprise-solutions.swits.n...=auto-format-time-on-lostfocus&c=infopath2003
, it is virtually impossible to do this for your situation, since the fields
are within a repeating table. So my conclusion is that you will have to use
code to re-format the time. The best place to do this is in the OnAfterChange
event of a time field and using logic that takes the time apart and then
checks and changes the minutes based on criteria, e.g. if the amount of
minutes is less than 7 then re-format time field to the hour, if the amount
is between 7 and 22, then re-format to the quarter hour etc.
 

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