In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more here
Start Free Trial

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
19 - Altair
19 - Altair

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