Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to convert String to date in talend

hi,
i have date which is in string "MM/dd/yyyy" and i want to convert same format in DATE data type in talend,
means
"MM/dd/yyyy" data type(String) ---> MM/dd/yyyy data type(DATE)
how could i do this please provide the solution.
thanks and regards
Shailendra Shukla

Labels (2)
67 Replies
Anonymous
Not applicable
Author

Hi Team,
Need your input on this.
Database : oracle 12c
Talend : v6.1 DI enterprise version
We have a table A which contains LAST_RUN_DATE column with TIMESTAMP datetype. Need to insert data for this column would be as below like 
current_date+ "00:30:00" i,e I need to concatenate current date with timestamp(hardcoded value) as shown.  We are using tFixedFlowinput to populate the LAST_RUN_DATE column value and expression given is 
TalendDate.formatDate("dd/MMM/yyyy HH:mm:ss",TalendDate.parseDate("dd-mm-yyyy HH:mm:ss",context.To_Date).
 Here context.To_Date variable datatype is STRING and same for To_DateTime. 
context.To_DateTime ="00:30:00";
context.To_Date= TalendDate.getDate("dd-MM-yyyy")+' '+context.To_DateTime;
We are not able to insert the value in the above format specified.seems like formatting issue. Could you help us with the format to get the desired output. 
Expected value to be inserted  for today for example should be  LAST_RUN_DATE:  31-MAY-16 00:30:00:000  
The date format in oracle DB for LAST_RUN_DATE column in Table A is  31-MAY-16 14.02.43.000000000.  
Thanks,
Sanjay
Anonymous
Not applicable
Author

How to convert  Unparseable date: "20161003" which is in string format to Date format i used above scenario but it is not working for me
Thanks
cterenzi
Specialist
Specialist

Assuming that the string is year+month+day, TalendDate.parseDate(TalendDate.parseDate("yyyyMMdd",row1.dateField ) should convert the string to a date.
(replace row1.dateField with the name associated with your "20161003" value)
Anonymous
Not applicable
Author

Thanks it worked for me 0683p000009MACn.png
I wanted to know one more thing.
I want to log error in file 
suppose while insert/update a row of records some records are failed to update/insert I want to log those failed records list into a file like suppose
id  name phone  city
1   shivi   999     Bangalore  -- > updated successfully in db 
2   arun   888     lucknow    ----> this record not updated successfully
3  atul    7777    Kanpur      ---- > record updated successfully ( in component I have unchecked die and error option) to run smoothly my job
I want in error log file 
"2 arun  888 lucknow "  this is failed record which I want in log error file 
can this be possible I tried tlogcatcher but it does not do like this which I wanted 
please help it will be good breakthrough searching a lot about it but not getting

Thanks.
Shivi
Anonymous
Not applicable
Author

Hi , 
I would like to convert date from string format "yyyyDDmm" to Date format "yyyy-MM-dd" .
May i know the correct Expression in Talend ?
Anonymous
Not applicable
Author

Hi , 
I would like to convert date from string format "yyyyDDmm" to Date format "yyyy-MM-dd" .
May i know the correct Expression in Talend ?
vapukov
Master II
Master II

Hi , 
I would like to convert date from string format "yyyyDDmm" to Date format "yyyy-MM-dd" .
May i know the correct Expression in Talend ?

post #61 - just edit it by Your needs
amitsave
Contributor
Contributor

Hi,

I have my source data in the format - 01-JAN-2001 in a string field.

Column has some Null values. I get the below error when i am trying to convert it to date data type.

 

TalendDate.parseDate("dd-MON-yyyy",row1.date_of_intro)

 

Error:

java.lang.IllegalArgumentException: Illegal pattern character 'O'

 

My Target table has date pattern - "dd-MON-yyyy" for the column.