Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Remove the date and keep the rest

SoheylaSalimi
6 - Meteoroid

Hi,

I have a column of data where I need to remove the date and keep the rest. like this 7/24/2020340 ,10/30/20194 , I tried Substring([Releas Date],9) , but as the length of date is varies, it  is not working . Any suggestions  would be greatly .

 

5 REPLIES 5
DavidSkaife
13 - Pulsar

Hi @SoheylaSalimi 

 

Try

REGEX_Replace([Release Date], '\d+/\d+/\d{4}', '')

Note this will only work if the year is always 4 digits

SoheylaSalimi
6 - Meteoroid

Thank you , it works 😊

what about if I want to have the date in another column ??

DavidSkaife
13 - Pulsar

Hi @SoheylaSalimi 

 

As in split the date out? In that case use the Regex Tool in parse output mode and the following code:

 

(\d+/\d+/\d{4})(.+)

 

That will place everything after the date in a new field

 

DavidSkaife_0-1665055032977.png

 

ChrisTX
16 - Nebula
16 - Nebula

When you write           like this 7/24/2020340 ,10/30/20194

 

are the two dates on the same row, same column?

or same column, two different rows?

 

If they are in the same column, two different rows, and 

if the Year is always 4 characters...

 

You can use the RegEx tool with this expression:

 

.*\/\d{4}(.*$)

 

which translates to:

.*   find any character, zero to unlimited times

\/   followed by a slash (the \/ is because the / slash must be escaped by using the \ character)

\d{4}   followed by a digit (\d) exactly 4 times

(.*$)     followed by the group of characters you want to capture:  any character, zero to unlimited times, followed by end of string ($)

 

The website https://regex101.com/ helps test regular expressions

 

 

or you could try a combination of these functions in a Formula tool:

   ReverseString

   ReplaceFirst    (replace first / with an unusual character like a tilde ~ or a pipe symbot |)

   ReverseString

 

Then use the Text to Columns tool, and use the unusual character as the delimiter

 

Chris

SoheylaSalimi
6 - Meteoroid

Thank you , it worked .

Labels