Calculate time difference in MySQL -


select empno , date_created ,  min(case when status = 0 time_created end) time_in, max(case when status = 1 time_created end) time_out biometrics empno = 3 group empno , date_created  

in syntax determines first in , last out of employee ask how can calculate time difference or total time of his/her between first in , last out of employee.

for example employee' first in 9:00:00 , last out 16:00:00 in afternoon. how can compute total hours work of employee?

please try following:

select    empno,    date_created,    time_in,    time_out,    time_format(timediff(time_out, time_in), '%h:%i') total_time   (   select empno, date_created,      min(case when status = 0 time_created end) time_in,     max(case when status = 1 time_created end) time_out   biometrics   empno = 3    group empno, date_created ) t1; 

Comments