将登记和签出格式分隔为列日期时间数据类型msssql

I need to separate the checkintime column as AM as checkin and PM as checkout;

enter image description here

Try this query .. in like clause add your search criteria.

SELECT CASE
         WHEN checktime LIKE '%AM%' THEN LEFT(checktime, Charindex(' ', checktime) - 1)
         ELSE name
       END,
       CASE
         WHEN checktime LIKE '%PM%' THEN RIGHT(checktime, Charindex(' ', Reverse(checktime)) - 1)
       END
FROM   YourTable 

For more check here

Or try this solution -

select ParsedData.* 
from MyTable mt
cross apply ( select str = mt.String + ',,' ) f1
cross apply ( select p1 = charindex( ',', str ) ) ap1
cross apply ( select p2 = charindex( ',', str, p1 + 1 ) ) ap2
cross apply ( select Nmame = substring( str, 1, p1-1 )                   
                 , Surname = substring( str, p1+1, p2-p1-1 )
          ) ParsedData

For more info click here

</div>

I have developed an Attendance system few days ago. Most of the time attendance machines just save a log for your entry. If an employee punches 5 times there will be 5 entry in that day for that employee. What I did I separated all the entries for a single day of an employee and took the first and last entry for check-in and check-out. Querying with AM/PM is not a good idea, both check-in or check-out can be AM or PM.