Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.
Free Trial

Alteryx Designer Desktop Discussions

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

String to date format

PhuongTran52
7 - Meteor

Hi,

 

Thank you for viewing this question

I have a column named Month with string value, for example: 042017, 052018

I need to do 2 things:

1. Change this into a date format: 04-2017 (or at least the column is read as a time format)

2. Add a new column to define the Month_Name: Apr, May (without the year)

 

I tried DateTimeParse as follow: DateTimeParse([Month], "%b") but it returns null value

 

Thank you in advance

3 REPLIES 3
Luke_C
17 - Castor
17 - Castor

@PhuongTran52 

 

You're on the right track with your thinking. You first need to parse the date using a datetimeparse function, then you can use a datetimeformat function to get the month. See attached for an example. 

JosephSerpis
17 - Castor
17 - Castor

Hi @PhuongTran52 I've mocked up a workflow that produces the output you describe. However the only valid date format alteryx will recognize as valid date data format is YYYY-MM-DD.

 

Dates_09032021.JPG

RolandSchubert
16 - Nebula
16 - Nebula

Hi @PhuongTran52 ,

 

I think you need 3 formulas to get the required output:

 

1. convert the string to a date format (date is always "YYYY-MM-DD" in Alteryx), based on your input data, the conversion will return the first day of the month

2. convert the date to the month format you need ("MM-YYYY")

3. find the month name

 

There are two DateTime functions you can use: DateTimeParse to convert a string to a date, and DateTimeFormat to create the output format you need. 

 

2021-03-09_16-56-01.jpg

 

Let me know if it works for you.

 

Best,

 

Roland

Labels
Top Solution Authors