One Star

unable to convert Numeric field to a date.

Hi I am trying to convert an integer to a date format using tMap but I keep getting errors.
I am importing a csv file and one of the fields is a date field stored as a number. The first 4 numbers is the year the next 2 numbers the month and the last 2 numbers the day.
E.g. 20130607 would be June 7th of year 2013. I want to convert the number to a date format as follows 07/06/2013.
At moment I can't even cast to a date format. I tried TalendDate.formatDate("yyyyMMdd",myDate) but I get the error 'myDate cannot be resolved to a variable'?
3 REPLIES
Moderator

Re: unable to convert Numeric field to a date.

Hi,
For your case, what's the input source? I think it should be row1.myDate? In addition, the method formatDate(String, Date). I think you should TalendDate.parseDate(String pattern, String stringDate) method into consideration.
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: unable to convert Numeric field to a date.

Great thank you. I was trying to cast an int to a Date in the destination table, but I can see in your example you set the Date format in the source data. Many thanks.
Moderator

Re: unable to convert Numeric field to a date.

Hi,
If you want to convert Int to Date, please refer to this forum Forum 10783
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.