Hello!
I am attempting to save a file in a different folder each month for a monthly audit that we perform.
I am using the following function to attempt to get "03 March" to be the end result, and I am in need of help to parse out the date to make that happen.
DateTimeAdd(DateTimeParse(dt,f)DateTimeLastOfMonth(),-1,"months")
The bolded portion is the part I am confused on.
So before I add the DateTimeParse function, I get 2018-03-30 23:59:59 as the output. I'd like it to output as "03 March", or Month Number then Month Name, all using the DateTimeAdd function so that I do not need to update the formulas each month.
Is this the right way to approach this, or is there a better way?
Many thanks.
Thanks so much!
Solved! Go to Solution.
@kevin-lindorfer I think you would want DateTimeFormat() instead. Something like this:
DateTimeFormat(DateTimeAdd(DateTimeLastOfMonth(),-1,"months"),"%m %B")
PS I can't keep DTFormat and DTParse straight either...
Hey @kevin-lindorfer!
Try adjusting your formula to look like the following:
datetimeformat(DateTimeAdd(DateTimeLastOfMonth(),-1,"months"),"%m %B")
I changed the DateTimeParse to DateTimeFormat and moved it to the beginning.
Hope this helps!
Thank you to both of you! I got those confused for sure :)
The desired field type that you're trying to achieve is a "String". It will actually be a variable length because the month names vary (V_String).
In creating this field, you might use a formula like you have below, but as it is nested with multiple functions being performed at once there may be some that will tell you to break the formula down to their individual components. Depending upon your comfort level with understanding the functions and the likelihood that you will need to maintain or train others in the details of the workflow, you may decide to take different configuration options.
https://help.alteryx.com/2018.1/index.htm#Reference/DateTimeFunctions.htm
DateTimeFormat([Date],"<Format>") is what you'll need. So for this example:
DateTimeFormat("2018-03-30",'%m %B")
Gets you your month.
Now to calculate the month prior to the current date.... I see lots of posts being made and will pause.
Cheers,
Mark