We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Multiple monthdateyear format conversion to Alteryx YYYY-MM-DD format

virgosquirrel
7 - Meteor

Hello, 

 

I've researched a few current thread about date format but I haven't able to resolve my date conversion to Alteryx format. 

My date column has different format such as: YYYY-MM-DD, mm/dd/yyyy, m/dd/yyyy, m/d/yyyy (with each letter represent 1 number, 2 letter represent 2 numbers)  and also blank. The one with the correct Alteryx format is YYYY-MM-DD I don't want to touch that. 

I used the Multi field formula to populate the Regex and Datetimeparse to convert my date format but it gave me the error (see attached screenshot) 

 

Can someone please help how I correct the formula below to get the conversion run? 

 

IF REGEX_Match([Hire Date], '(\d{2}/\d{2}/\d{4})') THEN

DateTimeParse([Hire Date],"%Y/%m/%d")

ELSEIF REGEX_Match([Hire Date], '(\d{4}/\d{2}/\d{2})') THEN

DateTimeParse([Hire Date],"%Y/%m/%d")

ELSEIF REGEX_Match([Hire Date], '(\d{4}-\d{2}-\d{2})') THEN

DateTimeParse([Hire Date],"%Y-%m-%d")

ELSEIF REGEX_Match([Hire Date], '(\d{2}-\w+-\d{4})') THEN

DateTimeParse([Hire Date],"%Y/%m/%d")

ELSEIF REGEX_Match([Hire Date], '(\d{4}/\d{2}/\d{2})') THEN

DateTimeParse([Hire Date],"%Y/%m/%d")

ELSE

NULL()

ENDIF

6 REPLIES 6
alexnajm
18 - Pollux
18 - Pollux

Your first condition seems odd - you are saying if the regex is \d{2}/\d{2}/\d{4} then convert via DateTimeParse([Hire Date],"%Y/%m/%d")? I think this is not correct

 

Seems like a similar issue for your 4th conversion! Check your Formula and see if you can fix these inconsistencies

virgosquirrel
7 - Meteor

Thanks , can you suggest what is the correct way for the regex formula ? 

alexnajm
18 - Pollux
18 - Pollux

@virgosquirrel if you built this Formula, I am sure you can edit it to work! For example, you are saying %Y/%m/%d needs to match the pattern \d{2}/\d{2}/\d{4}? No, most likely it should be \d{4}/\d{2}/\d{2}

 

You got it - just work through the steps!

virgosquirrel
7 - Meteor

I got it to work, thank you!

Qiu
21 - Polaris
21 - Polaris
virgosquirrel
7 - Meteor

Thank you ! Will do!

Labels
Top Solution Authors