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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.