cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How can I get Year and Previous Month Name ?

dunncrew
Deputy Chef III
Deputy Chef III

I have a report that has data up to the end of previous calendar month. I want to email it, with the subject line saying "Report as of November 2024" 

I can get December 2024 with this:

=today.in_time_zone("America/New_York").strftime(" %B %Y ")

But can't figure out how to subtract 1 month from it  Where do I put "- 1.months"  without a syntax error ?

 

2 ACCEPTED SOLUTIONS

shivakumara
Executive Chef I
Executive Chef I

Hi @dunncrew ,
 As per the requirement you need always a month ago ( i.e. if current month December then requirement to get November). Please correct me.

in that case we can use directly "1.months.ago.in_time_zone("America/New_York").strftime(" %B %Y ")"   to simply the solution.

Thanks and Regards,
Shivakumar K A

View solution in original post

gary1
Executive Chef III
Executive Chef III

To stick with your current formula you can do this:

=(today - 1.months).in_time_zone("America/New_York").strftime(" %B %Y ")

View solution in original post

6 REPLIES 6

This is great!

dunncrew
Deputy Chef III
Deputy Chef III

Thanks for both suggestions. At first it appeared your suggestions did not work.

I found a "bug" that if the variable was "DATE" type, changed to "STRING" , Workato remembers it used to be DATE and doesn't work, so I had to create new variables