Alteryx Designer Desktop Discussions

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

How to extract month and year from a date?

bjemison
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?

10 REPLIES 10
mmenth
11 - Bolide

Simple solution would be

 

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

CharlieS
17 - Castor
17 - Castor

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")

mmenth
11 - Bolide

This is a handy resource for datetime functions in Alteryx:

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

AnupD
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

 

 

bjemison
7 - Meteor

Thank you so much CharlieS. This did the trick!

Gopi11
5 - Atom

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

Dcode
5 - Atom

Thanks Charlie,

This was very helpful.

Sam7
8 - Asteroid

Did you ever get a reply?

 

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

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

Daniel-ogundijo
5 - Atom

Thanks CharlieS.

 

I have been trying to use the formula but it’s not working for me.

 

DateTimeFormat(DateTimeParse[Column heading],”%m-%d-%Y”), “%B”)

 

My date is this format 21-oct-22 and data type is V_WString.

 

I am new to Alteryx, please help

Labels