I have this table named time_track:
+----+--------+---------------------+---------+
| id | emplid | ctimestamp | eventid |
+----+--------+---------------------+---------+
| 1 | 13 | 2016-06-02 03:41:41 | 1 |
+----+--------+---------------------+---------+
| 2 | 13 | 2016-06-02 09:04:49 | 2 |
+----+--------+---------------------+---------+
| 3 | 13 | 2016-06-02 10:03:13 | 1 |
+----+--------+---------------------+---------+
| 4 | 13 | 2016-06-02 13:21:23 | 2 |
+----+--------+---------------------+---------+
where eventid 1 = Start work
and eventid 2 = Stop work
.
How can I calculate the hours of any given day taking into consideration that working hours are the total hours between all eventid's 1 and 2 - WHERE emplid = 13 AND Year(ctimestamp) = 2016 and Month(ctimestamp) = 06 and Day(ctimestamp) = 02