Reg-Ex date problem


#1

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


#2

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)


Beatport.com WSS by stevehero [Release, Single Track & Artwork tagging]
#3

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.


#4

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


#5

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

#6

... 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