join the two tables and pull the rows from the date range you need:
select * from table1 t1
left join table2 t2 on
(t1.id=t2.subid)
where table1.datefield between
2004-06-01 and 2004-07-01
order by datefield, subfield1
Then just process the data in PHP. No need to spend all day seeing if something in t1 has an entry in t2. If it does, then it'll return the corresponding t2 rows, else none. If you need to join on date (not really a normal way of doing things, but workable) then the join on clause would be:
join table2 t2 on
(t1.datefield=t2.datefield)
if you make it a left join then all the rows in the daterange will return, whether there's a match or not. A plain join will only return the rows in t1 that have a match in t2.