Refactor searchByDate