php - separate the check-in and check-out form a column datetime data type msssql -


i need separate checkintime column as checkin , pm checkout;

enter image description here

try query .. in clause add search criteria.

select case           when checktime '%am%' left(checktime, charindex(' ', checktime) - 1)           else name         end,         case           when checktime '%pm%' right(checktime, charindex(' ', reverse(checktime)) - 1)         end    yourtable 

for more check here

or try solution -

select parseddata.*   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


Comments