Turn D/M/YYYY into YYYY/MM/DD

Yes, this is a rather old thread, but it is worth to demonstrate a simplification for converting MDY date to YMD date.

The given MDY date (Month/Day/Year) should be a valid MDY value and can be of format ...
02/01/2009
02/1/2009
2/01/2009
2/1/2009
02/01/0009
02/01/09
02/01/9
02/1/09
02/1/9
2/01/9
2/1/09
2/1/9
... that means the year must be a 1- or 2- or 4-digit year, the month and day values must have 1- or 2-digits.

The result is a YMD (Year-Month-Day) date of format ...
2009-02-01
... that means, the year will be always a 4-digit year, the month and day values have always a 2-digit format, zero padded at the left side, if needed.
A given 1- or 2-digit year will not be automatically left padded with a century value (what century should be valid?), so that a given year of "9" or "09" will be padded to "0009".

$regexp($regexp(%DATE_MDY%,'(\d\d?)/(\d\d?)/((?:\d\d?)(?:\d\d)?)','0000$3-00$1-00$2'),'0*(\d\d\d\d)-0*(\d\d)-0*(\d\d)','$1-$2-$3')

DD.20110215.0952.CET