Hey there, How do I extract Month (February) and Year (2019) Separately from February 28, 2019?
Solved! Go to Solution.
you can use a datetimeparse formula within the formula tool.
datetimeformat(datetimeparse([field],"%B %d, %y"),"%B") would get you the month.
datetimeformat(datetimeparse([field],"%B %d, %y"),"%Y") would get you the year.
Hi,
I tried datetimeformat(datetimeparse([field],"%B %d, %y"),"%B") to get the month but receive an error Invalid month:'05-01' -- expected at least three letters
I just started learning Alteryx and need help
Thank you 🙂
@SS02My guess without seeing the data is that it's how your inputs are structured. It appears that your dates are numeric,
ie "05-01-2019"
Using %B in the datetimeparse formula is telling Alteryx that your date field is formatted as "May 01, 2019" So it's looking in this case for the full word of the month name.
You would want to use %m instead.
@neilgallen Thank you, that helps
How to convert month from the date e.g. if the date is 02-27-2017 , I need just Feb as a month and not the entire date. Please help.
Thank you,
Dwarkesh
in this situation you'll need to both parse the date from the string as it's a non-standard format, and then format the date accordingly.
something like:
datetimeformat(
datetimeparse([field],"%m-%d-%y"),
"%b")
would return "Feb" as the result in your example. We are using "datetimeparse" to get the date in a format alteryx can recognize, then the "datetimeformat" function to reformat it in the abbreviated month name.