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,
(Var.date==null || Var.date.isEmpty())? null : TalendDate.parseDate("MM/dd/yyyy",TalendDate.formatDate("MM/dd/yyyy",TalendDate.parseDate("MM/dd/yyyy",Var.date)))

You use a Var in your tMap? How to define it in your tMap?
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi , i have a source in excel with the following data
id name dateofbirth salary hiredate
1 xays 24/01/1994 100 05/07/2012
2 xyz 22/10/1991 200 04/02/2012
3 kjsdj 04/02/1990 300 14/01/2008
4 dfdkl 06/06/1989 400 16/02/2010
here rowno1 24/01/1994,dateofbirth is displaying in excel as a general format
and rowno2 22/10/1994 dateofbirth is displaying in excel as a general format
and rowno 4 16/02/2010 hiredate is displaying in excel as a general format. so while iam loading this from excel to target iam getting the following error
The cell format is not date in row1 date of birth
The cell format is not date in row2 date of birth
The cell format is not date in row4 hire date Because the above mentioned rows are in general format in excel sheet.
my expetation is i want to get all the rows from source to target
Anonymous
Not applicable
Author

Hi Mahadevank,
You can mention the data type of your dates as string while defining schema to fetch data from the excel file. Then using Talenddate.parsedate("mm/dd/yyyy", datestring) in tjavarow or any other component which supports expression, you can change the datatype of your fetched dates.
Hope this helps
Anonymous
Not applicable
Author

Hi, remytom
thank you for your fast response..........
Here i used parsedate expression TalendDate.parseDate("dd/MM/yyyy".row1.date) in tmap while fetching the data from excel and the date columns are as a string datatype as you said in your reply.

But if i used parsedate in tmap the complete date value has been changed like.....
row1 date is 24/01/1994 as changed to like this 01/12/95 and
row2. 22/10/1991 is changed to 10/10/19992
can you show me the screen shot please for this solution
Anonymous
Not applicable
Author

I am not getting your error. If you could give me the snapshot of your tmap, I could understand better. Attaching herewith the snapshot of my solution. (I have converted only one of the date columns here and it works)
0683p000009MAHZ.jpg
Anonymous
Not applicable
Author

Hi remytom,

Yes i did in the way you said and here iam getting half rows only ...........
Because in my job i wrote parse date funtion in tmap for dateofbirth, hiredate column so i got half result what about another column (Hiredate).
If i write the parse date function also for leavedate column means its providing error. see my screen shot for your review
0683p000009MA9L.jpg
Anonymous
Not applicable
Author

when you apply the conversion on both the columns, you are getting incorrect dates? Or some other error is coming up?
A screenshot of your tmap would be great!
Anonymous
Not applicable
Author

Hi remyton ,
when iam applying the conversion on single column, i got some rows of data.
But when Iam applying the conversion on both column iam getting some different error here..............
And i have some null row in leave date, is this a problem?
0683p000009MALk.jpg 0683p000009MA9M.jpg
Anonymous
Not applicable
Author

I am sorry .Your snapshot did not get uploaded. I am not able to understand the error you are getting. Could you paste the error message?
Anonymous
Not applicable
Author

Hi remytom
see my previous post there i uploaded my snopshot . That is the error i got .
i have applied parse date function for two column 1.dateofbirth,2.hiredate. when iam applying the parse date function for one more column leave date , i got the error.

In leave date column i have some null values, is this a problem?.............