0

Hello,

I try with the following query to calculate the working time of employees:

SELECT 
	TIME_FORMAT(
		ADDTIME(
			TIMEDIFF(TIMEDIFF(hour_end, hour_begin),(hour_pause)), 
			TIMEDIFF(TIMEDIFF(hour_end_o, hour_begin_o),(hour_pause_o))
				) ,'%H:%i'
				) AS total
FROM 
	hour

This works correct, if the pause is filled, if no pause is given, no total is displayed (NULL). How can I calculate the correct total, when pause is given or not?

1
Contributor
1
Reply
2
Views
9 Years
Discussion Span
Last Post by kvdd
0

It is solved, but I have it not solved in the query itself.
There where fields that has 0000-00-00 00:00 instead of 2008-02-05 00:00
Thus the build of my table was incorrect, so that MySQL cannot calculate:

(2008-02-05 10:00 - 0000-00-00 00:00) = 10:00

But my problem is gone, thanks.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.