# eg. (date=0112) (year=2008) NEED RESULT (year 2008-01-12)

**URL:** https://community.mp3tag.de/t/eg-date-0112-year-2008-need-result-year-2008-01-12/11621
**Category:** Support
**Created:** [February 21, 2011, 12:57am UTC](https://community.mp3tag.de/t/eg-date-0112-year-2008-need-result-year-2008-01-12/11621 "2011-02-21T00:57:18Z")
**Posts on this page:** 8
**Page:** 1

<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: [February 21, 2011, 12:57am UTC](https://community.mp3tag.de/t/eg-date-0112-year-2008-need-result-year-2008-01-12/11621/1 "2011-02-21T00:57:18Z")

</div>

Hi all,  
Its probably very simple when you know how but I've tried for hours to get this to work.

Basically I have two tags:  
**Year** :2008  
**Date** :0112

The result I am looking for is:  
**Year** :2008-01-12  
**Date** :0112

So all in all I just need to copy the contents of the date field to the right of the year and have the **Year:** in the format **YYYY-MM-DD** as this is what trakor Pro (DJ software) uses to read the release date all the while keeping the **Date:** field intact.

Please see my settings below probably _ **very** _ wrong 😕

Thanks in advance

![](https://community.mp3tag.de/uploads/default/original/2X/9/98f35362ecb3eec65d4d2d6a09ca6b66f52ec7e6.jpg)

---

<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 21, 2011, 1:53am UTC](https://community.mp3tag.de/t/eg-date-0112-year-2008-need-result-year-2008-01-12/11621/2 "2011-02-21T01:53:21Z")

</div>

> [@stevehero](#):
>
> ...Basically I have two tags:  
> **Year** :2008  
> **Date** :0112  
> The result I am looking for is:  
> **Year** :2008-01-12  
> **Date** :0112  
> ...  
> Please see my settings below probably _ **very** _ wrong 😕  
> ...

Yes the screenshot shows, that you have tried something worse.  
What should the function $char(4) do in this context?  
Did you ever looked into the manual or read through the FAQ section on this board?

Because of missing delimiter characters, there is no way to use the action "Guess values" in it's normal way. To solve your problem I would use an action "Format value" together with a function $regexp().  
Field: YEAR  
Formatstring: **$regexp(%YEAR%%DATE%,'(\d\d\d\d)(\d\d)(\d\d)','$1-$2-$3')**

DD.20110221.0355.CET

---

<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: [February 21, 2011, 2:22am UTC](https://community.mp3tag.de/t/eg-date-0112-year-2008-need-result-year-2008-01-12/11621/3 "2011-02-21T02:22:56Z")

</div>

**IT WORKED**

THANK YOU for the very quick reply.

> [@](#):
>
> What should the function $char(4) do in this context?

It was my last attempt at getting it to work, it was just one of many things I tried. I also tried replace with regular expression. But I guess I was totally wrong!!

> [@](#):
>
> Did you ever looked into the manual or read through the FAQ section on this board?

Yes I looked through these for reference many times and found many things which helped, but this is the most complicated thing I've tried so far!

I'm sorry for being such a pain but I was wondering if you could take this one step further by saying:

**IF** the year is in the format: **YYYY-MM-DD** then it populates it with the date: **MMDD**

and vice-versa

**IF** the date is in the format: **MMDD** then it populates it with the year: **YYYY-MM-DD**

And it wont keep adding the **MMDD** to the year tag. e.g. **YYYY-MM-DD-MM-DD** and so on.

Just like a double argument. (I hope you can understand)

---

<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: [February 21, 2011, 11:02am UTC](https://community.mp3tag.de/t/eg-date-0112-year-2008-need-result-year-2008-01-12/11621/4 "2011-02-21T11:02:07Z")

</div>

> [@stevehero](#):
>
> I'm sorry for being such a pain but I was wondering if you could take this one step further by saying:
> 
> **IF** the year is in the format: **YYYY-MM-DD** then it populates it with the date: **MMDD**
> 
> and vice-versa
> 
> **IF** the date is in the format: **MMDD** then it populates it with the year: **YYYY-MM-DD**
> 
> And it wont keep adding the **MMDD** to the year tag. e.g. **YYYY-MM-DD-MM-DD** and so on.
> 
> Just like a double argument. (I hope you can understand)

this writes YYYY-MM-DD to %year% IF %year% has four digits AND IF %date% has four digits:  
Action: Format Value  
Field: YEAR  
Formatstring: $if($eql($regexp(%year%,^\d{4}$,yes),yes),$if($eql($regexp(%date%,^\d{4}$,yes),yes),$regexp(%year%%date%,(\d{4})(\d{2})(\d{2}),$1-$2-$3),%year%),%year%)

this writes MMDD to %date% IF %date% is NOT already four digits AND IF %year% is written like YYYY-MM-DD:  
Action: Format Value  
Field: DATE  
Formatstring: $if($eql($regexp(%date%,^\d{4}$,yes),yes),%date%,$if($eql($regexp(%year%,^\d{4}-\d{2}-\d{2}$,yes),yes),$regexp(%year%,(\d{4})-(\d{2})-(\d{2}),$2$3),%date%))

combine both actions in a action group and you've got what you want

EDIT:  
The second action will not write MMDD to %date% if the actual year is written as %date% as it might be the case with some files. Because YYYY and MMDD are both four digits and can't kept apart easily.  
To workaround this, I have three ideas:

IF %year% is written like YYYY-MM-DD ...

1. ... always overwrite %date%:

$if($eql($regexp(%year%,^\d{4}-\d{2}-\d{2}$,yes),yes),$regexp(%year%,(\d{4})-(\d{2})-(\d{2}),$2$3),%date%)
1. ... overwirte %date% IF it is NOT already four digits OR IF it the first two digits are higher than "12" (and thus can't represent a month):

$if($eql($regexp(%date%,^\d{4}$,yes),yes),$ifgreater($left(%date%,2),12,$if($eql($regexp(%year%,^\d{4}-\d{2}-\d{2}$,yes),yes),$regexp(%year%,(\d{4})-(\d{2})-(\d{2}),$2$3),%date%),%date%),$if($eql($regexp(%year%,^\d{4}-\d{2}-\d{2}$,yes),yes),$regexp(%year%,(\d{4})-(\d{2})-(\d{2}),$2$3),%date%))
1. ... overwrite %date% IF it is NOT already four digits OR IF it is the same as the first four digits of %year%:

$if($eql($regexp(%date%,^\d{4}$,yes),yes),$if($eql($left(%year%,4),%date%),$if($eql($regexp(%year%,^\d{4}-\d{2}-\d{2}$,yes),yes),$regexp(%year%,(\d{4})-(\d{2})-(\d{2}),$2$3),%date%),%date%),$if($eql($regexp(%year%,^\d{4}-\d{2}-\d{2}$,yes),yes),$regexp(%year%,(\d{4})-(\d{2})-(\d{2}),$2$3),%date%))

---

<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: [February 21, 2011, 2:45pm UTC](https://community.mp3tag.de/t/eg-date-0112-year-2008-need-result-year-2008-01-12/11621/5 "2011-02-21T14:45:19Z")

</div>

> [@pone](#):
>
> this writes YYYY-MM-DD to %year% IF %year% has four digits AND IF %date% has four digits:  
> Action: Format Value  
> Field: YEAR  
> Formatstring: $if($eql($regexp(%year%,^\d{4}$,yes),yes),$if($eql($regexp(%date%,^\d{4}$,yes),yes),$regexp(%year%%date%,(\d{4})(\d{2})(\d{2}),$1-$2-$3),%year%),%year%)
> 
> 1. ... overwirte %date% IF it is NOT already four digits OR IF it the first two digits are higher than "12" (and thus can't represent a month):
> 
> $if($eql($regexp(%date%,^\d{4}$,yes),yes),$ifgreater($left(%date%,2),12,$if($eql($regexp(%year%,^\d{4}-\d{2}-\d{2}$,yes),yes),$regexp(%year%,(\d{4})-(\d{2})-(\d{2}),$2$3),%date%),%date%),$if($eql($regexp(%year%,^\d{4}-\d{2}-\d{2}$,yes),yes),$regexp(%year%,(\d{4})-(\d{2})-(\d{2}),$2$3),%date%))

OMG pone. You made that look very easy. THANK YOU SO much. It Works.

I've used the above quotes to solve the problem.

Only thing is say I have the year as _ **2011-01-01** _ (The Traktor Pro DJ software usually messes the tag up like this) changing the _ **MM-DD** _ all to _ **01-01** _

So if its possible to take the values from the date as priority.

eg. problem:

**Year:** 2011-01-01  
**Date:** 0312

What i'm getting at the minute is the result:

**Year:** 2011-01-01  
**Date:** 0101

Correct Result:

**Year:** 2011-03-12  
**Date:** 0312

Thanks again for your time

---

<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: [February 21, 2011, 4:08pm UTC](https://community.mp3tag.de/t/eg-date-0112-year-2008-need-result-year-2008-01-12/11621/6 "2011-02-21T16:08:13Z")

</div>

> [@stevehero](#):
>
> OMG pone. You made that look very easy. THANK YOU SO much. It Works.
> 
> I've used the above quotes to solve the problem.
> 
> Only thing is say I have the year as _ **2011-01-01** _ (The Traktor Pro DJ software usually messes the tag up like this) changing the _ **MM-DD** _ all to _ **01-01** _
> 
> So if its possible to take the values from the date as priority.
> 
> eg. problem:
> 
> **Year:** 2011-01-01  
> **Date:** 0312
> 
> What i'm getting at the minute is the result:
> 
> **Year:** 2011-01-01  
> **Date:** 0101
> 
> Correct Result:
> 
> **Year:** 2011-03-12  
> **Date:** 0312
> 
> Thanks again for your time

Action: Format Value  
Field: YEAR  
Formatstring: $if($eql($regexp(%year%,^\d{4}$,yes),yes),$if($eql($regexp(%date%,^\d{4}$,yes),yes),$regexp(%year%%date%,(\d{4})(\d{2})(\d{2}),$1-$2-$3),%year%),$if($eql($regexp(%year%,^\d{4}-01-01$,yes),yes),$if($eql($regexp(%date%,^\d{4}$,yes),yes),$regexp(%year%%date%,(\d{4})-(\d{2})-(\d{2})(\d{2})(\d{2}),$1-$4-$5),%year%),%year%))

This does the following:  
IF %year% = 4 digits  
...IF %date% = 4 digits  
...-\> YYYY-MM-DD from the values in %year% and %date%  
...ELSE  
...-\> keep %year% YYYY as it is  
ELSE  
...IF %year% = 4 digits-01-01  
......IF %date% = 4 digits  
......-\> YYYY-MM-DD from the values in %year% and %date% (overwriting 01-01 in year)  
......ELSE  
......-\> keep %year% YYYY-MM-DD as it is  
...ELSE  
...-\> keep %year% YYYY-MM-DD as it is

Or in the script language:  
$if($eql($regexp(%year%,^\d{4}$,yes),yes),

```
$if($eql($regexp(%date%,^\d{4}$,yes),yes),
    $regexp(%year%%date%,(\d{4})(\d{2})(\d{2}),$1-$2-$3),
    %year%),
$if($eql($regexp(%year%,^\d{4}-01-01$,yes),yes),
    $if($eql($regexp(%date%,^\d{4}$,yes),yes),
        $regexp(%year%%date%,(\d{4})-(\d{2})-(\d{2})(\d{2})(\d{2}),$1-$4-$5),
        %year%),
    %year%))

```

(this might be the longest formatstring i've ever written)

---

<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: [February 21, 2011, 5:28pm UTC](https://community.mp3tag.de/t/eg-date-0112-year-2008-need-result-year-2008-01-12/11621/7 "2011-02-21T17:28:36Z")

</div>

> [@](#):
>
> this might be the longest formatstring i've ever written

YA DONT SAY!! lol (Handy Little thing to have though)

I actually went 😳 trying to figure out how you done it!!

Honestly I cant thank you enough. I would bever have gotten there without you.

**UR A LEGEND**

**\*\*CASE CLOSED\*\***

---

<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:22pm UTC](https://community.mp3tag.de/t/eg-date-0112-year-2008-need-result-year-2008-01-12/11621/8 "2026-02-09T12:22:56Z")

</div>


