Condition on date field is not working