• Login
Community
  • Login

How to change date format from from MM/DD/YY to DD/MM/YYYY

Scheduled Pinned Locked Moved General Discussion
4 Posts 3 Posters 21.4k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y
    Yusuf Qureshi
    last edited by Dec 2, 2016, 6:18 AM

    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.

    1 Reply Last reply Reply Quote 0
    • G
      gerdb42
      last edited by Dec 2, 2016, 8:20 AM

      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.

      G 1 Reply Last reply Dec 2, 2016, 8:36 AM Reply Quote 0
      • G
        gerdb42 @gerdb42
        last edited by Dec 2, 2016, 8:36 AM

        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.

        1 Reply Last reply Reply Quote 0
        • G
          guy038
          last edited by guy038 Dec 2, 2016, 9:28 PM Dec 2, 2016, 9:01 PM

          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 and 49 values, we rewrite the string 20, followed by the year value

          • If the year is between the 50 and 99 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
          
          1 Reply Last reply Reply Quote 0
          2 out of 4
          • First post
            2/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors