Alteryx Designer Desktop Discussions

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

How to Extract Month from Date

chughes49
8 - Asteroid

Hey there, How do I extract Month (February) and Year (2019) Separately from February 28, 2019?

8 REPLIES 8
JosephSerpis
17 - Castor
17 - Castor

Hi 

    This example should be give you the result you want?

neilgallen
12 - Quasar

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.

 

MarqueeCrew
20 - Arcturus
20 - Arcturus
Or:

GetWord([field],0) and GetWord(...,2) might work too.

Cheers,

Mark
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
SS02
5 - Atom

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 🙂

neilgallen
12 - Quasar

@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.

SS02
5 - Atom

@  Thank you, that helps

DwarkeshT
5 - Atom

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

neilgallen
12 - Quasar

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.

Labels