Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

TfilterRow with Date type

Hi,
I need filter data on Date type column with a context variable of the same type (Date). I use allowed operator (<,>,== etC..) but i have a error message.
" The method compareTo(String) in the type String is not applicable for the arguments (Date)"
Have-you a solution?
Thinks.
Labels (2)
10 Replies
Anonymous
Not applicable
Author

Hello
" The method compareTo(String) in the type String is not applicable for the arguments (Date)"

As the error message shows, you should convert Date to String first. You can use the TalendDate provided by Talend to convert it, for example:
TalendDate.formatDate("yyyy-MM-dd", row1.date)
If you still have problem, please upload some screenshot of your job and show us your expected result.
Best regards

shong
Anonymous
Not applicable
Author

hello. i'm beginner in TOS.
i have the same case as
TalendDate.formatDate("yyyy-MM-dd", row1.date)
but i'want to change the row1.date as a variable like this :
TalendDate.formatDate("yyyy-MM-dd", myVariable)
where am i put the variable and how to write the code ?
thank you,
regards
capricornday
Anonymous
Not applicable
Author

Hello capricornday
Can you tell us more infomation about what are you doing and what are your expected result?
where am i put the variable and how to write the code ?

On tJava/tJavaRow/tMap, you can write the code like this:
String date=TalendDate.formatDate("yyyy-MM-dd", myVariable)
Best regards

shong
Anonymous
Not applicable
Author

Thanks for your answer, Shong.
I have these component
tMysqlInput --------> tFilterRow1 ----------> tFilterRow2 ---------> tAggregate ---------> tMySQLOutput
dbA : table 1 (where ...) (where date =...) (group by...) dbB : table 1?
^
|
t..?
At tFilterRow2 i need to filter the date
on , but from other component/input.
And can i save the output in different database ?
Because on the learning i've try it in the same database ex : dbA : table 2.
i'm sorry if maybe this is a newby question 0683p000009MACn.png
thank you
regards'
capricornday
Anonymous
Not applicable
Author

Hello
At tFilterRow2 i need to filter the date
on , but from other component/input.

Please see my screenshot.
And can i save the output in different database ?

Yes, you can insert the result into different target database.
Best regards

shong
Anonymous
Not applicable
Author

thanks to Shong for the answer.
I change the type column : dwdate from date into string
and put "input_row.dwdate.equals("2008-03-31")"
It's works! thanks 0683p000009MACn.png
Do you have any solution if i still use date format
regards
capricornday
Anonymous
Not applicable
Author

Hello
Do you have any solution if i still use date format

If you use date format, you can convert it to string on tMap before you filter as above, then parse string to date again.
Best regards

shong
Anonymous
Not applicable
Author

Hello shong
Thanks for your information the other day.
I've try to used tMap as shown on the picture,
column dwdate change into string.
but i have an error message :
Type mismatch: cannot convert from Date to String.
what should i do?
Best regards
capricornday
Anonymous
Not applicable
Author

Hello
but i have an error message :
Type mismatch: cannot convert from Date to String.
what should i do?

You need to convert date to string, type in the following code in expression field of dwdate column.
TalendDate.formatDate("dd-MM-yyyy", row1.dwdate)
Best regards

shong