ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
GELÖST

How to extract month and year from a date?

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

14 ANTWORTEN 14
mmenth
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
Bolide

This is a handy resource for datetime functions in Alteryx:

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

AnupD
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
Meteor

Thank you so much CharlieS. This did the trick!

Gopi11
Atom

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

Dcode
Atom

Thanks Charlie,

This was very helpful.

Sam7
Asteroid

Did you ever get a reply?

 

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

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

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

Beschriftungen
Top-Lösungs-Autoren