Error unsetting an empty expiration date #9422

After some help from @PVince81 I managed to get this right.

Please review.