Hi ! It's me again to give it another try 
declare @tablea table( ssn int, applicationtime datetime)declare @tableb table( ssn int, admissiontime datetime, dischargetime datetime)insert into @tableaselect 1234, '1/1/2005' union allselect 1234, '2/1/2006' insert into @tablebselect 1234, '1/9/2005', '1/23/2005' union allselect 1234, '2/7/2006', '3/31/2006'select a.ssn, a.applicationtime, b.admissiontime, b.dischargetimefrom @tablea a inner join @tableb b on a.ssn = b.ssn and a.applicationtime <= b.admissiontime and b.admissiontime = (select top 1 y.admissiontime from @tablea x inner join @tableb y on x.ssn = y.ssn and x.applicationtime = a.applicationtime and x.applicationtime <= y.admissiontime order by datediff(day, x.applicationtime, y.admissiontime) )/* RESULTssn applicationtime admissiontime dischargetime ----------- ------------------------ ------------------------- -----------------------1234 2005-01-01 00:00:00.000 2005-01-09 00:00:00.000 2005-01-23 00:00:00.0001234 2006-02-01 00:00:00.000 2006-02-07 00:00:00.000 2006-03-31 00:00:00.000(2 row(s) affected)*/
KH