[resolved] Retrieve last months name from a variable i.e. May

One Star

[resolved] Retrieve last months name from a variable i.e. May

I am using tSetGlobalVar to create variables for use in the subject line of a tSendMail component. I would like to show that month name in the subject line i.e. TalendDate.getDate("MMMM") June. However I would like to show the prior month i.e. May. Talend obviously knows the months. I can retrieve the prior month using the following:
TalendDate.addDate(TalendDate.getDate("MM/dd/yyyy") , "MM/dd/yyyy", -1,"MM")
TalendDate.getPartOfDate("MONTH",TalendDate.parseDate("yyyy-MM-dd", ((String)globalMap.get("dateStamp"))))
The problem being that this was a manual process that is now being automated and the request is to have the subject line of the email contain last months name rather than 5/2014.
I am using Talend Enterprise Data Integration Cluster edition 5.0.2.r78327
We plan to upgrade to 5.3 in the next quarter.
Thanks in advance

Accepted Solutions
Seventeen Stars

Re: [resolved] Retrieve last months name from a variable i.e. May

You solution is a bit cumbersome.
This expression will give you the name of the previous month (just today it return May)
TalendDate.formatDate("MMM", TalendDate.addDate(TalendDate.getCurrentDate(), -1, "MM"))

All Replies
Seventeen Stars

Re: [resolved] Retrieve last months name from a variable i.e. May

You solution is a bit cumbersome.
This expression will give you the name of the previous month (just today it return May)
TalendDate.formatDate("MMM", TalendDate.addDate(TalendDate.getCurrentDate(), -1, "MM"))
One Star

Re: [resolved] Retrieve last months name from a variable i.e. May

Thank you for your help. Your answer has expanded my understanding of the formatDate and addDate functions.