Alteryx Designer Desktop Discussions

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

Deriving previous month name and year(Aug-2021) from datetimetoday()

Idyllic_Data_Geek
8 - Asteroid

I was wondering if there is an easy calculation to get previous month name and year from datetimetoday(). For example if I run my workflow today or anytime in month of September I need to capture Aug-2021 in a field.

Thanks in Advance for your help!

5 REPLIES 5
RolandSchubert
16 - Nebula
16 - Nebula

Hi @Idyllic_Data_Geek ,

 

DateTimeFunctions can help.

DateTimeFormat(DateTimeAdd(DateTimeToday(), -1, 'month'), '%b-%Y') will return what you need. DateTimeAdd finds the previous month, and DateTimeFormat creates the requested formant. The result field has to be a string data type.

 

Let me know if it works for you.

 

Best,

 

Roland

Luke_C
17 - Castor

Hi @Idyllic_Data_Geek 


I agree with @RolandSchubert's solution. I'd suggest bookmarking the below page. I reference it constantly when working with dates.

 

https://help.alteryx.com/20213/designer/datetime-functions

 

Idyllic_Data_Geek
8 - Asteroid

It worked like a charm. Thank you

Idyllic_Data_Geek
8 - Asteroid

what formula can I use to subtract the below 2 fields which are VWstring data type?

 

Idyllic_Data_Geek_0-1641310876525.png

 

Luke_C
17 - Castor

Hi @Idyllic_Data_Geek 

 

You'd need to use DateTimeParse to convert to dates, then DateTimeDiff. I have it set to get the difference in months, but you could change 'month' to 'day' if needed. 

 

datetimediff(datetimeparse([Today_Month],'%B, %Y'),datetimeparse([Report Month],'%B, %Y'),'month')

 

Luke_C_0-1641311630271.png

 

Labels