• something like this?

    table t(accountid, active, [datetime])

    select *

    from t

    where accountid = 1010100

    and datetime between startdate and dateadd(ms, 86399997, enddate)

    order by [datetime]

    this would return all active/inactive events during a date range for a given account