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

Inconsistent Date format (string)

doublej
7 - Meteor

I have a field that contains date values, currently a string field, that has multiple formats that i need to convert to an actual date field.  The current values are "yyyy-mm-dd" and "mm/dd/yyy".  I have tried the DateTime parse tool but with multiple formats this isnt successful.  Anyone run across this?

 

11 REPLIES 11
NeilR
Alteryx Alumni (Retired)

Here is the blog post that goes along with the macro. The last paragraph might help point you in the right direction.

pvara
8 - Asteroid

Hi Mark,

your formula works great, I tried to add another condition for my use case. my date could come in as:

 

20200610 therefore would like it output as 2020-06-10

my current result looks like 2020--30

 

Thank you

 

IF
Contains([date],"-") THEN date
ELSEIF
Contains([date],"/") THEN Regex_Replace([date],"(\d{1,2})(/)(\d{1,2})(/)(\d{4})","$5-$1-$3")
ElSEIF
Contains([date],"") THEN Regex_Replace([date],"(\d{4})(\d{1,2})(\d{1,2})","$1-$5-$3") ELSE Null() ENDIF

 

 

Labels