Date field with conditions not working