Mysql employee monthly working hours calculation

Table name:

How to calculate january month total working hours employee code like emp0001

i need mysql query anybody know

create table employee ( id int(11),emp_code varchar(10),in_time time(),out_time time(),created_date date());

please post the results of a SHOW CREATE TABLE command

create table employee ( id int(11),emp_code varchar(10),in_time time(),out_time time(),created_date date());

is it possible for an employee to punch in late one evening and punch out early the next day?

if so, to which time does the date apply?

if not, why not?

this doesn’t a matter.

could you please be a bit more specific

because if it doesn’t matter, then your query doesn’t matter either

1 Like

I think you may have missed the point r937 was getting at. For example

My normal hours are 3 to 11 PM

One day (say Tuesday) I have to do overtime and I don’t leave until after midnight, say, until 1 AM (Wednesday).
I leave and come back at 3 PM staying until 11 PM

Wednesday now has 2 rows. Does the 1 hour overtime go to Tuesday or to Wednesday?

If Tuesday was January and Wednesday was February, which month does that hour belong to?

this is my database fields

is it possible for an employee to punch in late one evening and punch out early the next day?

if so, to which time does the date apply?

if not, why not?

ALSO: your datatypes are, shall we say, sub-optimal… INT for date? FLOAT for time?

sorry date_in field datatype Date

punching time not a matter i need total hours working particular employee

SELECT SUM( -something- ) AS total_hours_working
  FROM database
 WHERE user_id = 937

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.