Fixes #5388 throw exception if date is not valid