Hello
What is the best way to do this?
I have an employee database, which stores working hours of each employee. I insert the time when employee comes to work and when he/she leaves. Values in MySQL are for example in monday: field 'monday_1'= 08:14 and 'monday_2'= 16:44.
I want to get daily working hours of an employee, like "7.6" hrs etc... as a decimal number. I need this to build weekly and monthly working hour reports.
Thanks for any help.
time calculations
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
TIMEDIFF is probably not the best route, if you want decimal forms..
Using some math, you can use UNIX_TIMESTAMP against the time values..
Using some math, you can use UNIX_TIMESTAMP against the time values..
Code: Select all
SELECT ((UNIX_TIMESTAMP( monday_2 ) - UNIX_TIMESTAMP( monday_1 )) / 3600) AS hrs FROM your_table