Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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| '----------+----------'
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| '----------+----------'
Thank you so much Mr. Vapukov. Highly appreciate the timely help. It worked and returned as stated by you i.e 1-01-2018 ...
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"?
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.