Try this code.
declare @CHECKINOUT table
(
EMPID int,
CHECKTIME datetime
)
declare @EMP table
(
EMPID int
)
declare @TIMECARD table
(
EMPID int,
outTime datetime
)
insert into @EMP values(1)
insert into @EMP values(2)
insert into @EMP values(3)
insert into @CHECKINOUT values (1,'10-07-2013 10:00 am')
insert into @CHECKINOUT values (1,'10-07-2013 05:00 pm')
insert into @CHECKINOUT values (2,'10-07-2013 10:00 am')
insert into @CHECKINOUT values (2,'10-07-2013 05:30 pm')
insert into @CHECKINOUT values (1,'11-07-2013 10:00 am')
insert into @CHECKINOUT values (1,'11-07-2013 03:00 pm')
insert into @CHECKINOUT values (3,'11-07-2013 09:00 am')
insert into @CHECKINOUT values (3,'11-07-2013 05:30 pm')
select c.* from @CHECKINOUT c inner join @EMP e on e.EMPID=c.EMPID
Where convert(date,CHECKTIME,112) = '10-07-2013'
insert into @TIMECARD
select c.EMPID,max(c.CHECKTIME )
from @CHECKINOUT c inner join @EMP e on e.EMPID=c.EMPID
Where convert(date,CHECKTIME,112) = '10-07-2013'
group by c.EMPID
select * from @TIMECARD