Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Don't forget to submit your entry for the Excellence Awards by October 30! | Need more information about the program? Check out the blog here
SOLVED

How to extract month and year from a date?

Highlighted
7 - Meteor

I would like to convert a date field to month-year (e.g. convert 03-25-2019 to March-2019, or Mar-2019, or 03-2019, the format isn't really important to me.) I know that I can extract the year and the month from a date by using Datetimeyear() and Datetimemonth() respectively but what if I want to extract both?

Highlighted
11 - Bolide

Simple solution would be

 

Datetimeformat([Date], '%B-%Y')

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

The first step will be to reformat the input of "03-25-2019" into the Alteryx/ISO 8601 date format of "YYYY-MM-DD". You can do this with the following formula:

 

DateTimeParse([Input],"%m-%d-%Y")

 

Then it's just a matter of reformatting this into the desired output. In this case:

 

DateTimeFormat([ISO8601],"%B-%Y")

 

Both steps can be combined with one formula step:

 

DateTimeFormat(DateTimeParse([Input],"%m-%d-%Y"),"%B-%Y")

Highlighted
11 - Bolide

This is a handy resource for datetime functions in Alteryx:

https://help.alteryx.com/10.1/Reference/DateTimeFunctions.htm

Highlighted
8 - Asteroid

Try one of these in Formula tool:

 

DateTimeFormat([Date],'%b-%Y') or DateTimeFormat([Date],'%B-%Y') or DateTimeFormat([Date],'%m-%Y')

 

Various format options can be found here:

http://downloads.alteryx.com/betawh_xnext/Reference/DateTimeFunctions.htm

 

 

Highlighted
7 - Meteor

Thank you so much CharlieS. This did the trick!

Highlighted
5 - Atom

How can I get Year/Month in Numeric format from there itself. I dont want to go any step like select function.

Highlighted
5 - Atom

Thanks Charlie,

This was very helpful.

Highlighted
7 - Meteor

Did you ever get a reply?

 

I found this https://help.alteryx.com/10.5/Reference/DateTimeFunctions.htm

Datetimeformat([InvoiceDate], '%m-%Y')

Labels