One Star

[resolved] tFilterRow, comparing two dates

Hi,
I have to filter the rows from a database input and take only the ones where the date is bigger than "31-12-2011".
This part of the job looks like this:
tOracleInput_1 ------------> tFilterRow1 ------ ...
In the basic settings of tFilterRow1 I used advanced mode and my code is this:
TalendDate.formatDate("dd-MM-yyyy", CON_F_CONTRATOSx1.ID_MES_FEFAIN) > "31-12-2011"

When i try to run the job but I get an error saying that I can't use ">" with String types, how can I do this?

Thanks in advance,
Khor.
1 ACCEPTED SOLUTION

Accepted Solutions
One Star

Re: [resolved] tFilterRow, comparing two dates

Hi mpa and toos,
I'm a bit embarrassed, sometimes when I have a problem i'm too focused on solve it in one way to go back and think about it from the beginning. Now that you told me this simple solution I realized that it was a really newbie question, I'm sorry.
Thanks for answer my question that fast and give me what i needed and more,
Khor.
3 REPLIES
One Star mpa
One Star

Re: [resolved] tFilterRow, comparing two dates

Khor,
I think it would be better if you use this in a where statement in your query of the tOracleInput.
There it will work with the ">" operator and it will directly filter out the rows which will make your job faster.
Because right now you are getting all the rows from your database and then filtering. If you filter the data directly in your query it will only need to get the required rows from the database.
If you still want to use your method by using the tFilterrow, then you should try the following:
TalendDate.compareDate(myDate1,myDate2,"yyyy-MM-dd") > 0
Hope it works :-)
Regards
Five Stars

Re: [resolved] tFilterRow, comparing two dates

I suggest :
TalendDate.compareDate(
TalendDate.formatDate("dd-MM-yyyy", CON_F_CONTRATOSx1.ID_MES_FEFAIN),
TalendDate.formatDate("dd-MM-yyyy", "31-12-2011"))
One Star

Re: [resolved] tFilterRow, comparing two dates

Hi mpa and toos,
I'm a bit embarrassed, sometimes when I have a problem i'm too focused on solve it in one way to go back and think about it from the beginning. Now that you told me this simple solution I realized that it was a really newbie question, I'm sorry.
Thanks for answer my question that fast and give me what i needed and more,
Khor.