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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to convert a column having only month names(string) to date in talend

Hi All,

 

Can you pls help out with this at the earliest. I have a dataset in which i have a column containg month names namely Jan, Feb... which i want to convert to date type. 

I tried using tMap in which i used parseDate.

I also tried using tConvertType but it throws an error as unable to parse the date "Jan"

java.text.ParseException: Unparseable date: "Jan" and so on...

I did convert the datatype to date and ticked autocast and used the relevant syntax in parseDate.. Pls can someone help

Labels (2)
1 Solution

Accepted Solutions
vapukov
Master II
Master II

tTypeConvert - will not work

but tMap - easy

TalendDate.parseDate("MMM",row1.month) 

the problem is - it will always return 1970-month-01 because you do not know - what year?

 

for example for the current year, the function could be:

TalendDate.parseDate("yyyy-MMM",TalendDate.formatDate("yyyy",TalendDate.getCurrentDate())+"-"+row1.month) 

result for first and second:

.----------+----------.
|      tLogRow_1      |
|=---------+---------=|
|date      |date2     |
|=---------+---------=|
|1970-01-01|2018-01-01|
|1970-02-01|2018-02-01|
|1970-03-01|2018-03-01|
'----------+----------'

 

View solution in original post

4 Replies
vapukov
Master II
Master II

tTypeConvert - will not work

but tMap - easy

TalendDate.parseDate("MMM",row1.month) 

the problem is - it will always return 1970-month-01 because you do not know - what year?

 

for example for the current year, the function could be:

TalendDate.parseDate("yyyy-MMM",TalendDate.formatDate("yyyy",TalendDate.getCurrentDate())+"-"+row1.month) 

result for first and second:

.----------+----------.
|      tLogRow_1      |
|=---------+---------=|
|date      |date2     |
|=---------+---------=|
|1970-01-01|2018-01-01|
|1970-02-01|2018-02-01|
|1970-03-01|2018-03-01|
'----------+----------'

 

Anonymous
Not applicable
Author

Thank you so much Mr. Vapukov. Highly appreciate the timely help. It worked and returned as stated by you i.e 1-01-2018 ...

zalibra
Contributor III
Contributor III

hi @vapukov 

 

i have a string field coming in with "ABC0215" which i need to convert to the current date. i've used the expression 

TalendDate.parseDate("MMdd", (StringHandling.RIGHT(row5.symbol2, 4))) 

but, as you mentioned earlier, it converts to 1970. tried various steps to get to 2020, but can't figure it out. would you know what the expression should be to get date "15-02-2020"?

zalibra
Contributor III
Contributor III

actually, figured it out. 

 

TalendDate.parseDate("yyyyMMdd", TalendDate.formatDate("yyyy", TalendDate.getCurrentDate())+ (StringHandling.RIGHT(row5.symbol2, 4))) 

thank you for pointing me in the right direction.