RE: [PHP-DB] payperiods
Ok, that makes sense. I have all the payperiods specified in a table to begin with, then just query selecting all >= start && <= end. Thanks, - Darren On Tue, 2002-11-12 at 11:29, Peter Beckman wrote: > 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. > > Peter > > > 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 BeckmanSystems 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 -- 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
RE: [PHP-DB] payperiods
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. Peter 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 BeckmanSystems 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
RE: [PHP-DB] payperiods
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
RE: [PHP-DB] payperiods
I don't know what your application or requirements are, but here's something to think about... If each pay period will ALWAYS be in two week increments from the date you hard code, then you're fine just hard coding the first one and incrementing automatically after that. However, if you're in one of those situations where you get paid every two weeks but there is an odd number of days left over at the end of the year and you have to pay those out in the current calendar year, you may run into a snag. In that case, your pay period may have to encompass 17 days or 11 days instead of the normal 14. Not sure what your overall application is for, but I know this has crept up to bite me once before. Because of this, you might want to give your user(s) an input field or two to enter a start and end date for the first pay period. After that, have the remaining ones populate automatically based on a two-week increment and allow the dates to be edited as required. Most of the time, the dates will be able to be left alone. Probably only the last ending date in December will ever have to be altered. Maybe that's not the best option, but I think you see where I'm going with this. I might be overthinking this, but I hated going back and changing my system. Just trying to save you unnecessary pain and suffering. > -Original Message- > From: Anderson, Jerrad [mailto:jerrad.anderson@;teds.com] > Sent: Tuesday, November 12, 2002 1:58 PM > To: Darren Bentley; [EMAIL PROTECTED] > Subject: RE: [PHP-DB] payperiods > > > I would think that the hard coded date is the way I'd do that. > > maybe not neccessarily a start_dt, but maybe a pay_pd_st > date. This date is just the date the payperiod falls on. You > increment it once every two weeks. Have a table in your db > with that field and variable. maybe hardcode the very first > date. and a pay period date. > > if on linux or unix you can run a cron job to increment that > date, or do some calculation to the hardcoded date when > displaying a calendar. > > hmm... i'm rambling.. > > -Original Message- > From: Darren Bentley [mailto:darren@;bcgroup.net] > Sent: Tuesday, November 12, 2002 1:51 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] payperiods > > > Hello, > > I have build a php calendar and want to implement 2 week payperiods so > staff can enter their hours worked. Then I can summarize work done per > pay period. > > Any idea what the easiest way to do this is? I could hard code a > starting date into a database, then go up 2 weeks at a time > from there. > Is there a better way? > > Thanks, > > -- > 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 > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] payperiods
I would think that the hard coded date is the way I'd do that. maybe not neccessarily a start_dt, but maybe a pay_pd_st date. This date is just the date the payperiod falls on. You increment it once every two weeks. Have a table in your db with that field and variable. maybe hardcode the very first date. and a pay period date. if on linux or unix you can run a cron job to increment that date, or do some calculation to the hardcoded date when displaying a calendar. hmm... i'm rambling.. -Original Message- From: Darren Bentley [mailto:darren@;bcgroup.net] Sent: Tuesday, November 12, 2002 1:51 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] payperiods Hello, I have build a php calendar and want to implement 2 week payperiods so staff can enter their hours worked. Then I can summarize work done per pay period. Any idea what the easiest way to do this is? I could hard code a starting date into a database, then go up 2 weeks at a time from there. Is there a better way? Thanks, -- 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] payperiods
$nextpayperiod = mktime(0,0,0,$month,$day+14,$year); $humanreadabledate = date("r",$nextpayperiod); where $month is numeric month, $day is the last payperiod day (1-31), and $year is the year of the payperiod. $nextpayperiod will equal the unix timestamp of 14 days from the last payperiod. Peter On 12 Nov 2002, Darren Bentley wrote: > Hello, > > I have build a php calendar and want to implement 2 week payperiods so > staff can enter their hours worked. Then I can summarize work done per > pay period. > > Any idea what the easiest way to do this is? I could hard code a > starting date into a database, then go up 2 weeks at a time from there. > Is there a better way? > > Thanks, > > -- > 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 BeckmanSystems 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