Start a new topic

RegEx remove timestamp, reformat date

Hoping to take this data: 2021-02-15T15:43:13Z

and remove timestamp + reformat to: 2/15/2021


Have you tried this one? https://support.omaticsoftware.com/support/discussions/topics/28000006357

It should at least be a good starting point


This is what I have for Time Stamp Removal

Replacement values = --BLANK-- (check Use Regular Expressions)

Values to match on = (?<=\d+/\d+/\d+\s+).*

This is what I have come up with:
Replacement: 
$2/$3/$1


Values to match on: 

^(\d{4})-(\d{2})-(\d{2})T.*


The only catch is this doesn't output quite what you wanted.  


For the sample data, this would output 02/15/2021


In other words, this retains the leading zeroes.  I'm not sure of a good way to tell regex to drop a character, but only if it's 0.  In other words, I could get it to always drop the leading digit when there's two, but you don't want that because it'll break month's 10,11, and 12, and every day of the month after 9.

Other restrictions: the above code only works if your input is formatted exactly as you specified above.  Specifically, it needs to have: 4 digits then a hyphen the two digits then a hyphen then two digits then a literal T, then whatever.

-- 
Isaac Comer


1 person likes this

That worked for me, thanks Isaac!

Login or Signup to post a comment