Implements query with date range.