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

**URL:** https://community.mp3tag.de/t/turn-d-m-yyyy-into-yyyy-mm-dd/9074
**Category:** Export
**Created:** [October 3, 2009, 10:09am UTC](https://community.mp3tag.de/t/turn-d-m-yyyy-into-yyyy-mm-dd/9074 "2009-10-03T10:09:41Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [February 15, 2011, 7:49am UTC](https://community.mp3tag.de/t/turn-d-m-yyyy-into-yyyy-mm-dd/9074/9 "2011-02-15T07:49:55Z")

</div>

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

---

_[View the full topic](https://community.mp3tag.de/t/turn-d-m-yyyy-into-yyyy-mm-dd/9074)._
