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?
Solved! Go to Solution.
Simple solution would be
Datetimeformat([Date], '%B-%Y')
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")
This is a handy resource for datetime functions in Alteryx:
https://help.alteryx.com/10.1/Reference/DateTimeFunctions.htm
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
Thank you so much CharlieS. This did the trick!
How can I get Year/Month in Numeric format from there itself. I dont want to go any step like select function.
Thanks Charlie,
This was very helpful.
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