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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

type mismatch : cannot convert from string to date

hello,
i need to set previous day date to fetch my previous day status records so i used this code .

" TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(), - 1, "dd")) "
by this code im getting previous day date but only in "string" format in stage variables but i want it in "date" format
if i changed that to "date" format it shows error like " type mismatch : cannot convert from string to date " .
how can i get the same in "date" format ? can anyone suggest me for this?

Thanks in advance
Nilesh
Labels (2)
8 Replies
Anonymous
Not applicable
Author

can anyone help me for this issue asap?
Anonymous
Not applicable
Author

Hi
The method formatDate returns a String, if want a date format, use this expression:
TalendDate.addDate(TalendDate.getCurrentDate(), - 1, "dd")
Best regards
Shong
Anonymous
Not applicable
Author

for that im getting like
"Wed May 25 14:58:56 GMT+05:30 2011"
but i need a output like "2011-05-25" in date format.
Anonymous
Not applicable
Author

Hi
Change the data type of column on schema to String, then you are able to use the expression as below to formate a Date to a String.
TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(), - 1, "dd"))
Best regards
Shong
Anonymous
Not applicable
Author

Ya this is what i used earlier .
now i need the same result(2011-05-18) but the datatype should be in date format because i need to merge it with my data which is in "date" datatype ..
Is "2011-05-18" format in "date" data type in talend tool....
Anonymous
Not applicable
Author

Hi
Is "2011-05-18" format in "date" data type in talend tool....

Yes, just set the date pattern as "yyyy-MM-dd", it will looks like "2011-05-18" in target.
Best regards
Shong
Anonymous
Not applicable
Author

yes i can change the format but if the data type is "date" it showing the same type mismatch error.
janhess
Creator II
Creator II

TalendDate.parseDate