|
-
Aug 23rd, 2005, 02:15 PM
#1
Thread Starter
Hyperactive Member
Totalling Hours
Hello,
I have a report that calculates the salaries of employees. In addition to that it calculates overtime hours. Now, I've been trying to work on a formula that would calculate the number of overtime hours. Which is supposed to be if an employee stayed for more than 8 hours at work. It would calculate the rest of the time as overtime. So let's say if an employee worked for 11 hours it would put in the field 3. Any ideas?
-
Aug 23rd, 2005, 02:34 PM
#2
Re: Totalling Hours
did you look at DateDiff you can add all working time with this function in minutes ("n"), subtract the amount of minutes that aren't overtime.
if the result is positive you've got overtime if it's negative to employee has taken some free time.
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Aug 24th, 2005, 03:21 AM
#3
Thread Starter
Hyperactive Member
Re: Totalling Hours
Well, actually, it's a little complicated than that. Because the employee can punchin and punchout twice on the same day. So perhaps what I was looking for is the sum of DateDiff per day and then calculate if it's over 8 hours then there is over time else there is no over time. If someone can give me a forumla it would really be appreciated. Thanx.
-
Aug 24th, 2005, 05:46 AM
#4
Re: Totalling Hours
Don't know why you cannot read the help files and experiment then post up that experiment...?
Perhaps something like:
Code:
Select
TheDateF,
sqryDiffs.TheTimeDiff as TotalHoursDay,
iif((sqryDiffs.TheTimeDiff * 24)>8,(sqryDiffs.TheTimeDiff * 24)-8,0) as OverTime
From
(select table.employeeid, format(table.thedate,'dd mmm yyyy') as TheDateF, sum(table.clockout-table.clockin) as TheTimeDiff
From table
Group By table.employeeid, format(table.thedate,'dd mmm yyyy')
) as sqryDiffs
The sub query gets each difference from clockin to clockout and sums them together, grouped by the employeeid and the date the record applies too (thedate).
The main query theen uses the total and works out if it is greater than 8 to subtract 8 to give the over time done.
Now the only possible problem is that the differences would be in fractions of a day (1 being 24 hrs) so I have added that in as well.
Try it and see if it works. If not perhaps you can change it to work correctly, or use it as a base to build a different solution.
good luck
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Aug 24th, 2005, 07:23 AM
#5
Thread Starter
Hyperactive Member
Re: Totalling Hours
So, I would make an SQL expression field, paste the following in it, right?
But what should substitute thedateF for?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|