One Star

[resolved] Convert data type string to time

Hi all,
I'm having real problem to upload one table of the db, online. I have a 'time' field in my table (initialy 'Time' database type and 'Date' type in tMap), which i read in tMap as a string and i want to convert it to time in the output. I have used these to methods
//TalendDate.formatDate("HH:mm:ss",row1.ora);
//TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",row1.ora);
..but none of them worked. What should i do? If you need more information just tell me, please! It's the first time i write here so i may be uncomplete..
P.S: The reason i run through this solution is because i couldn't export the 'ora' column as it's initial type. It always showed me the error pictured in pic a5.
Thanks in advance!
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] Convert data type string to time

Hi
Try this expression
TalendDate.parseDate("HH:mm:ss",row1.ora)
----------------------------------------------------------
Talend | Data Agility for Modern Business
11 REPLIES
Moderator

Re: [resolved] Convert data type string to time

Hi Mirela,
What is your source time? Is the date format yyyy-MM-dd HH:mm:ss?Such as, 2013-02-19 16:32:20?
Try this expression:
TalendDate.parseDate("yyyyMMddHHmmss",row1.ora)

Your feedback will be preferred.
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.

Re: [resolved] Convert data type string to time

Hi all,
I'm having real problem to upload one table of the db, online. I have a 'time' field in my table (initialy 'Time' database type and 'Date' type in tMap), which i read in tMap as a string and i want to convert it to time in the output. I have used these to methods
//TalendDate.formatDate("HH:mm:ss",row1.ora);
//TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",row1.ora);
..but none of them worked. What should i do? If you need more information just tell me, please! It's the first time i write here so i may be uncomplete..
P.S: The reason i run through this solution is because i couldn't export the 'ora' column as it's initial type. It always showed me the error pictured in pic a5.
Thanks in advance!

Hi Mirela,
Can you please share the image with the column details of row1.ora visible in tMap.
Also, i tried a case on my machine where i had a string input to tMap and have parsed it to date in output using TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",row1.ora) where the input string date was in the format "yyyy-MM-dd HH:mm:ss" for e.g. "2013-02-18 10:20:30" and the output in tMap was of Date datatype which can be in any format say "dd-MM-yyyy hh:MM:ss". It works fine for me.
Please find attached the image depicting the same.
Moderator

Re: [resolved] Convert data type string to time

Hi Mirela,
Do you job work well? Or there is still a problem?
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: [resolved] Convert data type string to time

hi
thanks for replying!
I tried this expression TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",row1.ora) as you guys said but still no result Smiley Sad
The ora column type in db is 'time'
Diwakar please find attached the pics you requested. I hope we'll get to a solution about this..
Best regards to both

Re: [resolved] Convert data type string to time

Diwakar please find attached the pics you requested.

Image missing..
One Star

Re: [resolved] Convert data type string to time

sorry i'm trying to upload them but apparently they won't show up .. Smiley Sad

Re: [resolved] Convert data type string to time

sorry i'm trying to upload them but apparently they won't show up .. Smiley Sad

Limits: 20 images per post, each image must be less then 1024x768 pixels and 200 KB
Make sure you comply to the above before attaching.

Re: [resolved] Convert data type string to time

Hi,
Can you also post the values of the source input string. I believe it is not in the correct format.
One Star

Re: [resolved] Convert data type string to time

Ora Input example: 06:15:00
The db type of the input is originally "time" , than it's converted to string by tConvertType.. goes into tMap as string.. out of tMap as string. I need now to reconvert it at least at "data" type otherwise i will need to convert it via a php function in the program that uses this database. But it would low down the performance of the program and that's why i need to reconvert it back from Talend.
Not sure if i was clear enough :/
Community Manager

Re: [resolved] Convert data type string to time

Hi
Try this expression
TalendDate.parseDate("HH:mm:ss",row1.ora)
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Convert data type string to time

It worked!!! Smiley Very Happy Smiley Very Happy Smiley Very Happy Thank you very much!! Smiley Happy))