Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[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
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

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"))

View solution in original post

2 Replies
Anonymous
Not applicable
Author

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"))
Anonymous
Not applicable
Author

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