Jump to content

[SOLVED] How to count Emplyee Hours from 2 Rows.. ?


Recommended Posts

The title is the best I could do to describe my problem.

I'm making an online Employee Time-Clock application for a client, and I'm getting progress, but I'm sorta stuck with something.

When an employee enters their ID and password, it inserts a row into a table called "timePunch" wit the data,

 

" ID - empID  -  activityID - timeYear - timeDate - timeMonth - timeHour - timeMinute - timeAP"

 

where empID is the ID of the employee. IF there is a row with their empID and activityID="In", then it inserts a row with their empID, and activityID="Out"

 

My question is, how can I calculate how many hours an employee has worked from counting the time from all the rows with their empID?

 

Thanks!

Yes I originally just had 1 column for the time, using time(), and it would work, BUT I need to allow to administrator to edit each time entry down to the minute. And The only way I knew how to be able to hold 5 areas of time, all of which are editable, is to have 5 separate columns....

Im a little confused. What happens after data has been entered twice? So the first time data is entered, it's listed as activityID as being IN? And the second time, its OUT? Then what?

 

And i'll add the third opinion - a timestamp would be much easier. To edit, you can always make the php script to format the timestamp into a more human readable form.

It just hit me on how to use date() instead of 5 different columns.. haha ill report back when i get it done.

 

Wait.. I know how to change the value of time() using date, inot a readble format, but how can i take a readable format and turn it into a value like time()

 

Because i will hold the time they punched in wit hthe time() function... but for the admin to edit it, they wil need to edit it in a readable form...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.