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

Transform string to date data type

Solonglolli
7 - Meteor

Hi there,

 

I'm a newbie and looking to convert ther records in a date field where the date is expressed in the format of '01-Jan-19' into the alteryx date format (yyyy-mm-dd). I have read through and tried a number of suggestions within this section and I still get the same error when using the DateTime parse tool. I have set the input data type to String and I have specified the incoming string field in a Custom format using different parameters including dd-Mon.-yy yet I always get the same error:

Solonglolli_0-1593000443369.png

Would anyone have an idea what is going wrong? Once successfully converted I'd like to assign a new column called quarter based on the dates.

Also is it better to use a syntax or the parse tool for converting dates to datetime?

Thanks!

3 REPLIES 3
RolandSchubert
16 - Nebula
16 - Nebula

Hi @Solonglolli ,

 

you can use the formula:

DateTimeParse([Field1], '%d-%b-%y') 

 

Let me know if it works for you.

 

Best,

 

Roland

Solonglolli
7 - Meteor

Thanks for the help and suggestion. An error came back first to say that the formula resulted in a string but the output field was set to numeric so i changed the output field to string and it was perfect then.

 

What is the default input and output date type for the datetime formula? Would the formula work with any kind of input data type or does it only work for string to be converted to string?

RolandSchubert
16 - Nebula
16 - Nebula

The input data type has to be a string (or to be converted to a string using ToString function), the output data type is always Date, DateTime or Time.
If you need a different output data type, you can use DateTimeFormat([DateField], 'Format') , (Format is the specification) returning a string.

Labels