complete the date filtering logic