How to Extract Month from Date
- 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
Hey there, How do I extract Month (February) and Year (2019) Separately from February 28, 2019?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
GetWord([field],0) and GetWord(...,2) might work too.
Cheers,
Mark
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@neilgallen Thank you, that helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
