Convert 7 or 8 character string into excel date

Today my wife asked me to fix one of her spreadsheets. One column contained a date encoded in either 7 or 8 characters in the format DMMYYYY or DDMMYYYY, but she needed the data as actual dates.

Here's the quick formula for this (assuming Y2 contains the date string):