Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
So, I've source string in the format 'MMddyyyy'("12012016") and I want to convert it into date 'MM-dd-yyyy'.
Is there a function in talend to convert this type? I used TalendDate.parseDate("MM-dd-yyyy",source.column) and its throwing-- Unparseable date: "12012016" error.
Any suggestions?
Thanks in advance
It is all string manipulation. You can also do something like the below:
yourDate.substring(0,2) + "-" + yourDate.substring(2,2) + "-" + yourDate.substring(4,4)
You can simply add "-" to each of the necessary positions.
In that scenario, the output will be still a string type not date, isn't it?
TalendDate.formatDate("MM-dd-yyyy", TalendDate.parseDate("MMddyyyy",yourDate))
That is what you want.
It is all string manipulation. You can also do something like the below:
yourDate.substring(0,2) + "-" + yourDate.substring(2,2) + "-" + yourDate.substring(4,4)
Thankyou!
It worked, I guess that is the only method, any other suggestions are welcome.
BTW slight correction in substring expression
yourDate.substring(0,2) + "-" + yourDate.substring(2,4) + "-" + yourDate.substring(4,8) as var1
and later I used TalendDate.parseDate("MM-dd-yyyy",Var.var1)
You're welcome. Thank you for the correction. I was doing it off memory so I apologize for the error. I was trying to beat others to the solution.
You could use TalendDate solution as well:
TalendDate.formatDate("MM-dd-yyyy", TalendDate.parseDate("MMddyyyy",yourDate))