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!
Solved! Go to Solution.
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
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
It worked like a charm. Thank you
what formula can I use to subtract the below 2 fields which are VWstring data type?
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')