views:

117

answers:

2

I'm usually a lot better than this, I promise.

Back story here: At my job, if you are late/absent, you get attendance points. One way to work attendance points off is to work weekend hours. For every 12 weekend hours you work, you get 2 attendance points removed.

For example, if an employee has 26 weekend hours built up, I need to subtract 24 hours, leaving a 2 hour remainder, and remove 4 points.

Right now I have all of this in Excel, but I could probably just as easily create a quick php/mysql, but that's be a pain. What's my best approach here? I was think mod functions, but... yeah. My head hurts. Someone point me in the right direction?

+5  A: 

Perhaps:

attendance_points -= (hours / 12) * 2 This assumes integer arithmetic.

then

hours = hours % 12

Does that help?

Are you allowed to use 6 hours in a chunk?

JoshD
I think this almost nails it.I honestly never thought about the 6 hour chunks, company policy is 12 hours.
nwalker85
+2  A: 

Basic update for each employee would look something like:

attendance_points -= weekend_hours / 12 * 2
weekend_hours %= 12

where / is integer division.

Andrew Cooper
I see we think alike. +1
JoshD