Fix the bug in detecting the exception if no date exists

The original way cannot raise a ValueError exception