Start a new topic

Regex to extract day of month from date-time

From a date-time field, or timestamp, I need to extract the day of the month.  For example, convert 07/13/2018 7:15:00 AM to just 13.


Hi Patrick - I just tested this one today that should work for you. I have exported the dictionary to csv and attached here. For anyone following along at home, this would be 2 Regex formulas in the following order:


Replacement Values                            Value to Match On

-BLANK-                                            (?<=\d+/\d+/\d+\s+).*

$2                                                    (\d{1,2})/(\d{1,2})/(\d{2,4})


First, deal with the timestamp, then just get the day, hope this helps!


Allison B.

csv
(97 Bytes)

I was not aware that you could have two functions process sequentially in the same regular expression.  I just learned two things at the same time - thanks Allison!

To be honest Patrick, most regular expressions are divas and don't share their dictionaries well with others - but in certain cases you can get away with it, just be mindful of the order of them to not contradict yourself. If the two expressions above were in the opposite order with the time stamp removal happening last instead of first, none of it will work!




Login to post a comment