Change if statement order to ensure dates are handled properly.