First-In and Last-Out times for Night Shift and Day Shift Employees
Could you write a query to use BETWEEN the shift start date time and the shift end date time (both held in variables) that returns all the SSN and check times in that period? If you insert the results of that into a temporary table, you could then have another query on that temporary table for your MIN and MAX values. Doing it like that means you don't need to worry about a change of date because your only concerned with the data in your temporary table. Also, using variables would let you reuse the script for different date and times for shifts.