Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Extract date from text

poojamate92
8 - Asteroid

I have a data set contains a text field that has a date embedded within the text. The goal is to fetch the date from that text. I had used DateTime parse tool to extract date from text but it did not work. So please provide me solution that how I can extract date from the lines of string statements.

 

The following attachment have input data with respective its output.

4 REPLIES 4
NicoleJohnson
ACE Emeritus
ACE Emeritus

I would suggest the Parse tools, specifically RegEx and DateTime tools.

 

RegEx = Use the following expression to split out the date from the string:

(\d{2}-[[:alpha;]]{3}-\d{4})

Use Parse method to put the results in a new field. RegEx will find the portion of the string that has 2 digits, a hyphen, 3 letters, a hyphen, and 4 digits, and put that in the parsed field.

 

DateTime = Use the DateTime tool to put the date in the right format. You'll just need to specify the format of the incoming date, so in this case it would be dd-Mon-yyyy. The tool will convert it to standard DateTime format, yyyy-mm-dd.

 

See workflow attached below... hope that helps! 

 

NJ

 

poojamate92
8 - Asteroid

Thank You Nicole Johnson.

 

Your Solution worked. Please suggest me where I refer syntax for regular expression.

NicoleJohnson
ACE Emeritus
ACE Emeritus
Sorry for the delay responding to your last question @poojamate92 - @SeanAdams once gave me a superb list of RegEx info when I was first learning, so I will pass them along! These were all great resources :)

Loads of good beginner regex on YouTube:

- https://www.youtube.com/watch?v=DRR9fOXkfRE for examples

Additionally there's a few good guides out there and helper sites

- https://community.alteryx.com/t5/Alteryx-Knowledge-Base/Tool-Mastery-RegEx/ta-p/37689

- http://www.rexegg.com/regex-anchors.html

- http://regexr.com/

- http://regex101.com

- http://www.rexegg.com/regex-quantifiers.html

- https://regexone.com/

Hope these help!
NJ
asteryx
8 - Asteroid

Just a note for others landing here:

Nicole's attached example works fine, but the RegEx in the text of the reply as a semicolon instead of a colon after "alpha".

 

Thanks for the helpful response, @NicoleJohnson!

Labels