corrected query for date filter