First-In and Last-Out times for Night Shift and Day Shift Employees Kindly share suitable technique to handle night shift as well as day shift.
Below are the shifts,
Night,  2020-07-20 17:00 to 2020-07-21 02:00
Night,  2020-07-20 17:00 to 2020-07-21 02:00
Day,    2020-07-20 08:00 to 2020-07-20 17:00
Day,    2020-07-20 08:30 to 2020-07-20 17:30

In Database there are only two fields
1: SSN (which is employee Code)
2: CheckTime e.x. (2020-07-20 16:48:30.000)

in Day shift i can get first in last out from Min entry and Max entry.
but in night shift I can't get any accurate data because of the date change.
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.