select distinct tcontent.siteid from tcontent inner join tcontent tcontent2 on tcontent.parentid=tcontent2.contentid
where tcontent.approved=1 and tcontent.active=1 and tcontent.display=2 and tcontent2.type <> 'Calendar'
and ((tcontent.displaystart >=#createodbcdatetime(application.lastmonitored)#
and tcontent.displaystart <=#createodbcdatetime(theTime)#)
or
(tcontent.displaystop >=#createodbcdatetime(application.lastmonitored)#
and tcontent.displaystop <=#createodbcdatetime(theTime)#))
group by tcontent.siteid