php - how to get total no of working hours with date & time in MYSQL with reference to checkin & checkout time -


below table shows checkin & checkout time of employee

emp_id report_date report_time    11     2014-12-01 08:02:31  21     2014-12-01 08:13:04  11     2014-12-01 18:03:41  21     2014-12-01 16:36:02 

you need convert time values seconds check post:

mysql: how difference between 2 timestamps in seconds

i'll share working code important understand going on it.

select `emp_id`, `report_date`, min(`report_time`) chekin,   max(`report_time`) chekout,  ( (time_to_sec(timediff(max(`report_time`), min(`report_time`))) / 60) / 60) difference   `your_table` 1 group `emp_id`, `report_date` 

first group employee id , report date, way 1 row each id on distinct date. select minimal time employee on given date, , max time. time difference in seconds, divide 60 in minutes, , divide again 60 in hours.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -