What is the best way to count the time between two datetime values retrieved from MySQL, when I only need to count the time between the hours of 08: 00: 00-16: 00: 00.
For example, if I have the values 2008-10-13 18:00:00 and 2008-10-14 10:00:00, the time difference should be 02:00:00.
Can this be done using SQL or what is the best way to do this? I am building a website and using PHP.
Thank you for your responses.
EDIT: Exactly, I'm trying to calculate the time when the “ticket” was in a certain state during business hours. Time can be like a couple of weeks.
EDIT2: I have no problem calculating the actual time difference, but by subtracting this departure time, 00: 00: 00-08: 00: 00 and 16: 00: 00-00: 00: 00 per day.
-Samuli
Samuli vainio
source share