Calling all Alteryx customers: Refer your colleague to try Alteryx and receive a $50 gift card. Sign up now!

Alteryx Designer Desktop Discussions

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

get the date inside a string

PassION_es
10 - Fireball

Hi Alteryx community

 

Requesting how to get a date from a string and convert it into a date? Examples:

 

Input:

Interim Report 04-17-24B

Interim Report 04-02-24

 

Output-date type:

04-17-2024

04-02-2024

 

Thank you

          

3 REPLIES 3
alexnajm
18 - Pollux
18 - Pollux

DateTimeParse(Regex_Replace([Input], ".+\s(\d\d-\d\d-\d\d).*", "$1"), "%m-%d-%y")

 

Note that your output date type is not a date in Alteryx - dates follow the ISO format yyyy-mm-dd. If you want it to be in the format you have above, you need to use a DateTimeformat to convert it back to a string in the format you want.

ChrisTX
16 - Nebula
16 - Nebula

Use two separate formulas:

 

1) output data type String, create new field F1:  REGEX_Replace([Original text], ".*(\d{2}\-\d{2}\-\d{2}).*", "$1")

 

2) output data type Date:  DateTimeParse([F1],"%m-%d-%y")

 

or combine the formulas into one.

 

Screenshot 2024-05-23 070107.png

 

 

Chris

Raj
16 - Nebula

@PassION_es 
formula to get your expected output

DateTimeFormat((DateTimeParse(Regex_Replace([Input], ".+\s(\d\d-\d\d-\d\d).*", "$1"), "%m-%d-%y")),"%m-%d-%Y")

hope this help.

Labels
Top Solution Authors