How to change date format from from MM/DD/YY to DD/MM/YYYY
-
I have a data in which I have a dates mentioned in MM/DD/YY which I want to convert it to DD/MM/YYYY, is there a easy way to convert the same.
-
The basic approach would be a simple RegEx Search&Replace:
Search for:
(\d{2})/(\d{2})/(\d{2,4})
Replace with:\2/\1/\3
Of course this is only a simple rearrangement of digits.
-
Ok, edits only allowed for 180 seconds, so I have to use a reply to self.
Overlooked the conversion from “YY” to “YYYY”.
search for :
\d{2}/\d{2}/\d{2}
replace with:\2/\1/20\3
Works only for Dates in the 2000s, of course.
-
Hello Yusuf and Gerdb42,
Gerdb42, I think that, annoyed about waiting 3 minutes to correct your post, your just omit the 3 groups to re-arrange the date :-))
So, Yusuf, the correct Gerdb42 S/R is, of course :
SEARCH :
(\d{2})/(\d{2})/(\d{2})
REPLACE :
\2/\1/20\3
Cheers,
guy038
P.S. :
Oh ! Thinking about the 2000’s years, here is an other solution :
SEARCH :
(\d{2})/(\d{2})/(([0-4])\d|[5-9]\d)
REPLACE :
\2/\1/(?{4}20:19)\3
So, supposing the year, written with TWO digits :
-
If the year is between the
00
and49
values, we rewrite the string 20, followed by the year value -
If the year is between the
50
and99
values, we rewrite the string 19, followed by the year value
For instance, the two dates :
12/15/49 01/15/50
would be changed into :
15/12/2049 15/01/1950
-