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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

using parseDate for string entry type

Hello,
I have a column (string) containing dates in the format yyyyMMdd or 0 when the date is not indicated. I am trying to convert the string to date using this expression

getData.name.equals("0") ? null:(TalendDate.parseDate("yyyyMMdd",getData.name)) 


but I have this error

Exception in component tMSSqlOutput_1
java.sql.SQLException: Only dates in the AD era are accepted.


When I tried with tlogrow to see if the conversion worked  after t_map, I have found that:
if I have  20060330 it returns 30-03-2006 ,but if it's 0 it returns 30-11-0002 , so it is not taking in account the first condition in my statement.
Do you have any Idea how to correct this?

Thank you

Labels (2)
4 Replies
Anonymous
Not applicable
Author

I do not think that it is a value of "0" that is yielding 30-11-0002 as it ought to throw an exception before hitting an SQL exception.
I also cannot see anything wrong with your "0" test, if that is what you're value is.
Anonymous
Not applicable
Author

Howerver it seems the case. Here is an example of a line from my source file and the output from the tlogrow component


example.zip.zip
Anonymous
Not applicable
Author

I don't think you're providing enough information.
Your tLogRow output is showing both String and Date Format values, so it can't be of Date type.
Your data is coming from Excel. Maybe something is going wrong before tMap. Try dropping in an additional tLogRow to see?
A screenshot of your tMap may also help.
Anonymous
Not applicable
Author

Exactly! putting tlogrow before tmap showed me the error!
The "0" in my excel file is shown as "00000000" in the tlogrow
Now my expression is right and it's working
row2.name("00000000") ? null:(TalendDate.parseDate("yyyyMMdd",row2.name)) 

Thanks a lot for your help!