String to date format
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Let me know if it works for you.
Best,
Roland
