One Star

date filter using in tMap

I tried to use expression filter in tMap. But I couldn't get it work for dates.
If I put, for example, row1.BIRTH_DATE >="01/01/1980", then I'll get the error message as
"The Operator>=is undefined for the argument type(s) Date, String"
If I put row1.BIRTH_DATE>=TalendDate.parseDate(?MM/dd/yyyy?,"01/01/1980"), I got the following "The operator >= is undefined for the argument type(s) java.util.Date, java.util.Date"
I don't know hot to make it the right way. Could anyone give me some corrections?

Re: date filter using in tMap

You should use Talend methods from TalendDate system routines.
For example,
* ->> compareDate(2008/11/24 12:15:25, 2008/11/24 16:10:35,"yyyy/MM/dd") return 0 #
public static int compareDate(Date date1, Date date2, String pattern) {
if (date1 == null && date2 == null) {
return 0;
} else if (date1 != null && date2 == null) {
return 1;
} else if (date1 == null && date2 != null) {
return -1;
if (pattern != null) {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
String part1 = sdf.format(date1), part2 = sdf.format(date2);
return (part1.compareTo(part2) >= 1 ? 1 : (part1.compareTo(part2) <= -1 ? -1 : 0));
} else {
long time1 = date1.getTime(), time2 = date2.getTime();
return (time1 < time2 ? -1 : (time1 == time2 ? 0 : 1));
syntax : TalendDate.compareDate(new Date(),new Date(),"yyyy-MM-dd")
Best regards,
One Star

Re: date filter using in tMap

I know it has been nearly 4 years since you asked this question, and I do not know if GAT originally answered your question successfully for you, but I found a MUCH simpler way of doing it and I figured I'd share my answer in case anyone else comes looking:
Basically, using a similar set up, I had to insert specific data from table A database A to table B database B, given a certain date they had to be greater than. I put all these dates into a table C in database B, but obviously had no way of querying both database A and B at the same time to extrac the correct data.
Using the tMap component, with the main input from table A and a lookup input from table C and then an output to table B, I mapped the columns I needed (not including the date columns from both tables A and C) and then typed in the following statement in the Expression Filter above the output in the tMap view to get only the data for the correct dates:
All_Source_Dates and Last_Target_Update_Date are my 2 date columns for tables A and C. The .after bit is what represents the ' > ' sign in sql code. You can interchange this with .equals and .before for similar commands.
I hope this comes in handy to anyone who looks it up.
V Pem.