added query to select datetime range