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: 
Sumit_1911
Contributor III
Contributor III

How to add hypen between month and last two values of year

I have an sql query which produces date in form of "MMYYYY". I want this value to pass through or output to one of the column in tMap as MM-YY. (The hypen should be inserted between month and year , and the year value should be taken the last two digits of the year). 

 

Can someone help in how to handle this , if in tMSSQLROW or though string handling in tMap.

 

Example :- What I am looking for is :-

122019- should be "12-19"

012020- should be "01-20"

 

Note:- I have tried to accomplice with the format function of SQL by making a custom query in the query box of tMSSQLRow but getting a Null value.

 

I am new to talend ,so I don't know if the above makes sense. But if it is , please let me know if someone has any suggestions.

Labels (3)
1 Reply
PhilHibbs
Creator II
Creator II

In a tMap it could be a Java expression like this:

inRow.inField.substring(0,2) + "-" + inRow.inField.substring(4,6)

The substring method takes the first character and one-past-the-last character, with a zero base.