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/\3Of 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\3Works 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\3Cheers,
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)\3So, supposing the year, written with TWO digits :
-
If the year is between the
00and49values, we rewrite the string 20, followed by the year value -
If the year is between the
50and99values, we rewrite the string 19, followed by the year value
For instance, the two dates :
12/15/49 01/15/50would be changed into :
15/12/2049 15/01/1950 -
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login