One Star

Convert string to date into a tMap

Hello,
I would like to convert the following string :
2016 Apr 12 05:30:35
into date to import it into a tOracleOutput from a tMap in the following format :
12/04/2016 05:30:35
but I encounter the error
Type mismatch cannot convert from string to date.
I tried different ways : expression with TalendDate.parseDate, date pattern
Any help would be nice
8 REPLIES
Moderator

Re: Convert string to date into a tMap

Hi,
Could you please show us your tMap editor screenshot?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Convert string to date into a tMap

Hi
Thanks for your reply, I did it.
So what I did is :
In expression filter on the right panel of the tMap I replaced row3.TIMESTAMP
by TalendDate.parseDate("yyyy MMM dd HH:mm:ss",row3.TIMESTAMP)
AND
on the table below I set the date pattern I would like to have :
"dd/MM/yyyy HH:mm:ss"
That's all
Moderator

Re: Convert string to date into a tMap

Hi,
Have you tried to use the built-in function TalendDate.parseDateLocale() to convert the string(text) data to a Date?
The expression should be:TalendDate.parseDateLocale("yyyy MMM dd HH:mm:ss",row3.TIMESTAMP ,"EN") 
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Convert string to date into a tMap

Hi,
No, what is the difference with what I did ?
Regards
Moderator

Re: Convert string to date into a tMap

Hi,
Is it working well for you when your use  the built-in function TalendDate.parseDateLocale()?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: Convert string to date into a tMap

RichardG:
Check this out for a better  understanding for date handling   : http://www.talendbyexample.com/talend-date-handling.html
regards john 
Five Stars

Re: Convert string to date into a tMap

Another strange idea 
Try to rearrange your Fields from the input schema.
It sound ridiculous
But i had some  Job's here with an Date Problem or an Lookup one  which i only rearrange the the Fields from the input schema.
In this point Talend is a little bit buggy 
regards john 



 
Moderator

Re: Convert string to date into a tMap

Hi,
Try to rearrange your Fields from the input schema.

Are you using studio 6.1.1? What does the expected result look like? Could you please show us the problem you are getting?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.