One Star

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.
10 REPLIES
Community Manager

Re: TfilterRow with Date type

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
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: TfilterRow with Date type

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
Community Manager

Re: TfilterRow with Date type

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
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: TfilterRow with Date type

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 Smiley Happy
thank you
regards'
capricornday
Community Manager

Re: TfilterRow with Date type

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
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: TfilterRow with Date type

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 Smiley Happy
Do you have any solution if i still use date format
regards
capricornday
Community Manager

Re: TfilterRow with Date type

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
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: TfilterRow with Date type

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
Community Manager

Re: TfilterRow with Date type

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
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: TfilterRow with Date type

hello shong.
great! Smiley Very Happy
thank you so much
regards,
capricornday