# Generating a date from Year/Week (Day Of Week)

**URL:** <https://community.mp3tag.de/t/generating-a-date-from-year-week-day-of-week/15765>\
**Category:** Support\
**Created:** [May 25, 2014, 1:54pm UTC](https://community.mp3tag.de/t/generating-a-date-from-year-week-day-of-week/15765 "2014-05-25T13:54:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcassidy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/a88e57/32.png) [@dcassidy](https://community.mp3tag.de/u/dcassidy)\
**Post date:** [May 25, 2014, 1:54pm UTC](https://community.mp3tag.de/t/generating-a-date-from-year-week-day-of-week/15765/1 "2014-05-25T13:54:34Z")

</div>

I have a situation where the only date related information in an MP3 tag is a  
4/6 charater field (or part thereof) indicating the Year and Week number.

I would like to be able to generate an ISO Date from this information.

Example: 201107 (or 1107) represents **Year: 2011**  **Week: 7** and of course we  
would provide it with a variable (1-7) of the Day of the week e.g. Wednesday = 3.  
The calculation would return **2011-02-16**

I tried several approaches which on my part didn;t get me very far such as  
Regex or the MP3Tag built in functions.

Can anyone suggest an approach to take,

Many thanks in advance,

Desmond.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [May 25, 2014, 3:47pm UTC](https://community.mp3tag.de/t/generating-a-date-from-year-week-day-of-week/15765/2 "2014-05-25T15:47:32Z")

</div>

perhaps an export to a csv-file and a subsequent treatment in Excel (or some similar) which has a set of powerful date functions.  
If you google for the calender-week to date calculation, you find loads of examples.  
You can then re-import the result, if you saved it in Excel as text-file.

---

<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:** [May 26, 2014, 6:40am UTC](https://community.mp3tag.de/t/generating-a-date-from-year-week-day-of-week/15765/3 "2014-05-26T06:40:44Z")

</div>

> [@Dezzz](#):
>
> I have a situation where the only date related information in an MP3 tag is a 4/6 charater field (or part thereof) indicating the Year and Week number. I would like to be able to generate an ISO Date from this information. ...

Mp3tag does not provide an easy way for mathematical calculation or conversion from year-week-day to year-month-day date values.  
But there is an easy way to solve the request by using a lookup-table.

For example ... for the ywd-value "2014221" look into the table of the year 2014 ...  
and get the corresponding ymd-value "2014-05-26".

Attached is an archive file with table files for each year from "1900" to "2100".

Extract the table files from the archive file into the folder "%APPDATA%\Mp3tag\data".  
By extraction there should be created the subfolder "Tables.Ywd.Ymd", which contains the various table files.

Create the action group ...

Begin Action Group **Format DATE#Get ISO Date from YearWeekDaynumber** 

Action #1  
_Actiontype 14:_ **Import text file**  
_Field \_\_:_ **DATE\_TABLE**  
_Filename:_ **$getEnv('MP3TAGAPPDATA')'\data\Tables.Ywd.Ymd\<!--colorc--\>'$left(%DATE\_YWD%,4)'.Table.Ywd.Ymd.txt'**

 

Action #2  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **DATE\_YMD**  
_Formatstring:_ **$regexp(%DATE\_TABLE%,'^._\n__'$replace(%DATE\_YWD%,'W',,'-',)'\s(\d\d\d\d-\d\d-\d\d)\r._$','$1')**

 

Action #3  
_Actiontype 9:_ **Remove fields**  
_Fields to remove (semicolon separated):_ **DATE\_TABLE**

 

End Action Group **Format DATE#Get ISO Date from YearWeekDaynumber** (3 Actions)

 

The string format for the input tag-field "DATE\_YWD" can be ...  
"2014221" or "2014W221" or "2014-W22-1"

 

How to use it?

 
1. Create the tag-field "DATE\_YWD" with the value "2014221".
2. Execute the lookup action.
3. Check the result in the tag-field "DATE\_YMD", should be "2014-05-26".

 

Erratum  
The initially published ywd-ymd-tables were not correct, because they miss the week W53.  
I have created a new set of ywd-ymd-tables, with each year containing a list of ywd values from "yyyy-W01-1" to "yyyy-W53-7".  
Now each table-file contains 53 weeks with 53\*7=371 ywd-values within one year.

 

Note: These tables are semantically not fully correct, because in some years some W53 ywd-values are not defined by the calendar system.  
But this does not harm the purpose of the simple lookup tables for ywd-to-ymd conversion.  
The tables are not made to validate a given ywd-value, regarding W53.

  20140526.Tables.YwdToYmd.zip ( 162.86K ) Number of downloads: 1

Test\_2014\_20140525.YWD\_to\_YMD.mta ( 266bytes ) Number of downloads: 5

  

[Tables.Ywd.Ymd.1900.2100.rar](https://community.mp3tag.de/uploads/default/original/2X/0/0357d4dfdf47a75a33ad240b0f06ae53fe8b3e92.rar) (202 KB)[Format\_DATE\_Get\_ISO\_Date\_from\_YearWeekDay.mta](https://community.mp3tag.de/uploads/default/original/2X/7/7ad59f6a3cea7ad5df5bee22ec14540225d376fa.mta) (284 Bytes)

 

After downloading rename the mta file to ...  
"Format DATE#Get ISO Date from YearWeekDay.v1.mta"

 

DD.20140526.1040.CEST, DD.20140526.2022.CEST, DD.20140528.1205.CEST, DD.20140530.1120.CEST

 

[Format\_DATE\_Get\_ISO\_Date\_from\_YearWeekDay.mta](https://community.mp3tag.de/uploads/default/original/2X/7/7ad59f6a3cea7ad5df5bee22ec14540225d376fa.mta) (284 Bytes)

 

[Tables.Ywd.Ymd.1900.2100.rar](https://community.mp3tag.de/uploads/default/original/2X/0/0357d4dfdf47a75a33ad240b0f06ae53fe8b3e92.rar) (202 KB)

---

<div class="post-metadata">

**Author:** ![dcassidy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/a88e57/32.png) [@dcassidy](https://community.mp3tag.de/u/dcassidy)\
**Post date:** [May 26, 2014, 5:07pm UTC](https://community.mp3tag.de/t/generating-a-date-from-year-week-day-of-week/15765/4 "2014-05-26T17:07:18Z")

</div>

Wow...Cheers...I'll give that a go !!!

Many Thanks...

---

<div class="post-metadata">

**Author:** ![dcassidy](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/a88e57/32.png) [@dcassidy](https://community.mp3tag.de/u/dcassidy)\
**Post date:** [May 29, 2014, 4:12pm UTC](https://community.mp3tag.de/t/generating-a-date-from-year-week-day-of-week/15765/5 "2014-05-29T16:12:17Z")

</div>

Worked a charm, many thanks;  
I didn't realize you could embed 'MP3TAG' functions within the search pattern of a  
Regexp function...  
Wonderful...

This approach now really has me thinking of othere 'little' problems I have had in the past with  
importing 'releted' data.

Cheers,

Desmond.

---

<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:** [May 30, 2014, 7:16am UTC](https://community.mp3tag.de/t/generating-a-date-from-year-week-day-of-week/15765/6 "2014-05-30T07:16:00Z")

</div>

> [@Dezzz](#):
>
> I have a situation where the only date related information in an MP3 tag is a 4/6 charater field (or part thereof) indicating the Year and Week number. I would like to be able to generate an ISO Date from this information. ...

Attached is a Mp3tag mta script, which calculates the ymd-value from the given ywd-value, without external lookup tables.

How to use it?

1. Create the tag-field "DATE\_YWD" with the value "2014221" or "2014-W221" or "2014-W22-1".
2. Execute the action.
3. Check the result in the tag-field "DATE\_YMD", should be "2014-05-26".

[Format\_DATE\_Get\_ISO\_Date\_from\_YearWeekDay.v2.mta](https://community.mp3tag.de/uploads/default/original/2X/6/60097d088e1dd7d2b7b8fe18ed7a21d124f917f2.mta) (3.8 KB)

After downloading rename the mta file to ...  
"Format DATE#Get ISO Date from YearWeekDay.v2.mta"

DD.20140530.1120.CEST

[Format\_DATE\_Get\_ISO\_Date\_from\_YearWeekDay.v2.mta](https://community.mp3tag.de/uploads/default/original/2X/6/60097d088e1dd7d2b7b8fe18ed7a21d124f917f2.mta) (3.8 KB)

---

<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:25pm UTC](https://community.mp3tag.de/t/generating-a-date-from-year-week-day-of-week/15765/7 "2026-02-09T12:25:04Z")

</div>

Closed on February 9, 2026, 12:25pm UTC


