Removed int casting for max/min so dates can also be used