Jump to content

Get The Total Hours Of Employee Attendance


newphpcoder
 Share

Recommended Posts

I upload .xml using php and it saves to database. I tried this data to upload:100603 10/1/11 5:35 AM 10/1/11 1:35 PM // this is the exact schedule of employee and its 8 hours per day he time in exactly and timeout exactly also, so no problem in computing because it is 8 hours.100603 10/2/11 5:25 AM 10/2/11 1:55 PM //in this example data the employee time in early in his schedule and time out late.100603 10/3/11 5:40 AM 10/3/11 1:40 PM // in this example data the employee time in is late, so even he also late to timeout theres no exemption because he late on his work. and it saves it database:100603 2011-10-01 05:35:00 2011-10-01 13:35:00100603 2011-10-02 05:25:00 2011-10-01 13:55:00100603 2011-10-02 05:40:00 2011-10-01 13:40:00 Now, I know that the data stored time in database formatted in 24 hours. Honestly, I want to accomplish is to get the total hours of the employee based on the employee no. and I tried this code:

select  sec_to_time(unix_timestamp(timeout) - unix_timestamp(timein)) AS totalhours from employee;

and the result of this code is: totalhours:08:00:0008:30:0008:00:00 and the result is the first is correct because the real schedule is 5:35 AM - 1:35 PMthe second is wrong it should be 8 hours only even he timein early and timeout late.the third is also wrong because the employee is late to timein, even he also timeout late., it should be deduct or subtract in hours the late of employee.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...