Project | Time In | Time Out ----------|---------|--------- Project X | 9.25 | 14.25 Project Y | 7.00 | 8.50
(I am representing the data as a decimal number of hours simply because it’s easy to read in the example; the data is actually MySQL TIMESTAMPs.) Assuming that the data is not in any particular order, I am wondering what would be the simplest and/or most optimized way to validate that the next entry does not conflict with the existing time in such a way that the employee is signed into two projects simultaneously. e.g. If the user tries to sign in at 12:00 PM or at 7:30 AM, it throws an error because the user was already working on Project X at noon and Project Y at 7:30. I know I could do this by getting all the time clock data and then detecting if time_in <= input[time] <= time_out, but I’m wondering if there’s a cleaner method to accomplish this task.
Asked By : M Miller
Answered By : Alexey Birukov
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/30492 3.2K people like this