Put the dates for employees into one table.

In another, put the payperiods.

You could populate the payperiods table for the next 90 years if you wanted
if it is always on a 2 week schedule.

To look at past payperiods:

  select start, end from payperiods where start = '$querydate';

Or just date, but you'll have to decide if the date in the payperiod table
will be the start of the payperiod or end of the payperiod. IE:

  select date as start,date_add(date,interval 14 day) as end from
  payperiods where start = '$querydate';

Then get the employees who put in time between those days, assuming $pp
contains the row found:

  select * from timesheets where date>={$pp[start]} and date<{$pp[end]};

Then you'd have all of the hours employees put in.  Then just sort by
employee name (add a group by) and/or sum their hours, etc.

Pretty easy.


On 12 Nov 2002, Darren Bentley wrote:

> Our payperiods will always be 2 week increments.
> So if I specify a starting day in the database I need to have that
> starting day always updated to the current starting day. (when we switch
> to the new payperiod), so as Jerrad mentioned I could use a cron job.
> But how would I be able to look at past payperiods? Lets say I want to
> view a payperiod from September, then this method won't work.
> I'm trying to automate this so employees don't have to specify dates.
> They just click the date on the calendar and enter their hours worked
> per task.
> Then the accountants can go to a "summaries" page where they can click
> on the staff member and view any current and past pay periods.
> This sounded easy when I first started :)
> Thanks again for the help!
> --
> Darren Bentley / Systems Administrator
> Borealis Internet / 1-800-667-0307
> Prince George, BC, Canada
> http://www.pgweb.com
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Peter Beckman            Systems Engineer, Fairfax Cable Access Corporation
[EMAIL PROTECTED]                             http://www.purplecow.com/

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to