How to update MYSQL Table and delete duplicate record more than one each day same ID

I have Attendance Table, and import table.
Import Table as Below

ID date_time
1001 2023-08-15 8:00:00
1002 2023-08-15 8:01:00
1001 2023-08-15 19:31:00
1002 2023-08-15 19:35:00

I get these data and inserting into Attendance Table, EMPID, TimeIN, TimeOUT
using Min(date_time) and max(date_time) my attendance table like below

EMPID TimeIN TimeOUT
1001 2023-08-15 8:00:00 2023-08-15 19:31:00
1002 2023-08-15 8:01:00 2023-08-15 19:35:00

but in the middle of the day if i import data my attendance table like below

EMPID TimeIN TimeOUT
1001 2023-08-16 8:21:00 2023-08-15 08:21:00
1001 2023-08-16 20:01:00 2023-08-15 20:01:00

I need to update attendance table TimeIN 8:21:00 and TimeOUT 20:01:00 and delete 2nd row

I tried created temporary table (att_duplicate) using below code
INSERT INTO att_duplicate SELECT EMPID, min(TimeIN) as TimeIN, max(TimeOUT) as TimeOUT, SN from attendance GROUP by EMPID, date(TimeIN) HAVING COUNT(TimeIN)>1 ORDER BY EMPID, TimeIN;

then i update attendance table join with att_duplicate table using below code
UPDATE attendance att JOIN att_duplicate dup ON att.EMPID = dup.EMPID AND DATE(att.TimeIN)= date(dup.TimeIN) SET att.TimeOUT = dup.TimeOUT, att.TimeIN = dup.TimeIN

Then i delete attendance table duplicate records using below code, but this take very long time..
DELETE a1 FROM attendance a1 JOIN attendance a2 ON a1.EMPID = a2.EMPID AND a1.TimeIN = a2.TimeIN AND a1.SN > a2.SN;

Is this wrong method, is there any better and faster way

I need better and fastest way