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 22.7k Views 1 Watching
    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.
    • Yusuf QureshiY Offline
      Yusuf Qureshi
      last edited by

      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
      • gerdb42G Offline
        gerdb42
        last edited by

        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.

        gerdb42G 1 Reply Last reply Reply Quote 0
        • gerdb42G Offline
          gerdb42 @gerdb42
          last edited by

          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
          • guy038G Online
            guy038
            last edited by guy038

            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

            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
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors