# Reg-Ex date problem

**URL:** https://community.mp3tag.de/t/reg-ex-date-problem/12786
**Category:** Support
**Created:** [December 6, 2011, 11:33pm UTC](https://community.mp3tag.de/t/reg-ex-date-problem/12786 "2011-12-06T23:33:57Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![privatewid](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/p/34f0e0/32.png) [@privatewid](https://community.mp3tag.de/u/privatewid)
#### Post date: [December 6, 2011, 11:33pm UTC](https://community.mp3tag.de/t/reg-ex-date-problem/12786/1 "2011-12-06T23:33:57Z")

</div>

Hi,  
Many of my tracks have both a DATE and a YEAR field and ideally I'd like to merge them and put the data in  
a custom field called DATEBACKUP. Here it should be safe from my DJ mix software that likes to  
screw up the DATE and YEAR fields!

My date info is stored as follows:  
DATE YEAR  
ddmm 2011

e.g.  
DATE YEAR  
3010 2011

I would really like them to be in the ISO date format, so, yyyy-mm-dd, and stored in the custom DATEBACKUP field.  
I've had a play with reg-ex and browsed the forum for tips but just can't get it.

Can anyone help?

Thanks  
Paul

---

<div class="post-metadata">

### Author: ![pone](https://community.mp3tag.de/user_avatar/community.mp3tag.de/pone/32/272_2.png) [@pone](https://community.mp3tag.de/u/pone)
#### Post date: [December 6, 2011, 11:45pm UTC](https://community.mp3tag.de/t/reg-ex-date-problem/12786/2 "2011-12-06T23:45:43Z")

</div>

Action: Format Value  
Field: DATEBACKUP  
Formatstring: %year%-$regexp(%date%,(\d\d)(\d\d),$2)-$regexp(%date%,(\d\d)(\d\d),$1)

the same result would be given by:  
Formatstring: %year%-$right(%date%,2)-$left(%date%,2)

---

<div class="post-metadata">

### Author: ![JJ\_Johnson](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jj_johnson/32/67_2.png) [@JJ\_Johnson](https://community.mp3tag.de/u/JJ_Johnson)
#### Post date: [December 6, 2011, 11:47pm UTC](https://community.mp3tag.de/t/reg-ex-date-problem/12786/3 "2011-12-06T23:47:33Z")

</div>

If the DATE field strictly conform to the four-digit mmdd format then it doesn't require a regex, you just grab the first two digits and the last two.

It could be as simple as

_Action type:_ **Format value**  
_Field:_ **DATEBACKUP**  
_Format string:_ **%year%-$right(%date%,2)-$left(%date%,2)**

If YEAR might be two digits it would be possible to add logic to add either 1900 or 2000 to the number.

---

<div class="post-metadata">

### Author: ![privatewid](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/p/34f0e0/32.png) [@privatewid](https://community.mp3tag.de/u/privatewid)
#### Post date: [December 6, 2011, 11:53pm UTC](https://community.mp3tag.de/t/reg-ex-date-problem/12786/4 "2011-12-06T23:53:30Z")

</div>

Yes the DATE field is strictly four digits and the YEAR is four also. Works perfectly, you guys are geniuses!  
Thanks,much appreciated.  
Paul

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [December 7, 2011, 1:26am UTC](https://community.mp3tag.de/t/reg-ex-date-problem/12786/5 "2011-12-07T01:26:28Z")

</div>

Another way to skin a cat :]

You can use this also.

_Name of action group:_ **&Script Test#DATEBACKUP**

Action #1:  
_Action type:_ **Format value**  
_Field:_ **DATEBACKUP**  
_Formatstring:_ **%year%-%date%**

Action #2:  
_Action type:_ **Replace with regular expression**  
_Field:_ **DATEBACKUP**  
_Regular expression:_ **^(\d{4})-(\d{2})(\d{2})$**  
_Replace matches with:_ **$1-$3-$2**

[] case-sensitive comparison

---

<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: [December 7, 2011, 2:36pm UTC](https://community.mp3tag.de/t/reg-ex-date-problem/12786/6 "2011-12-07T14:36:36Z")

</div>

> [@The Sheriff](#):
>
> Yes the DATE field is strictly four digits and the YEAR is four also....

... and even more cats are being skinned ...

Action: Format value  
Field: DATEBACKUP  
Formatstring: **%YEAR%'-'$num($mod(%DATE%,100),2)'-'$num($div(%DATE%,100),2)**  
... or ...  
Formatstring: **%YEAR%'-'$right(%DATE%,2)'-'$left(%DATE%,2)**

DD.20111207.1636.CET

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 9, 2026, 12:23pm UTC](https://community.mp3tag.de/t/reg-ex-date-problem/12786/7 "2026-02-09T12:23:29Z")

</div>


