How to validate two dates using conditions?