Ugly hack to use datetime for min and max