Fix invalid date error. Closes #1850