compareDate does not work at all

One Star

compareDate does not work at all

Hi,
I'm having some issues with the TalendDate.compareDate component.
I have 3 dates:
mainDate (coming from 1 flow)
date1 and date2 coming from another.
mainDate is entering a tMap from the main flow, the others date from a lookup one.
I can't match the two flows using a join, because I need to get informations based on if the mainDate is between date1 and date2. I need date1 <= mainDate < date2.
So i have my tMap like the image uploaded.
I think that Talend compare first the day, then the months and finally the year, which is an awful way to compare dates.
But maybe this is why there is a pattern, to choose how to compare, plus I saw a bug blog post saying that only the US/ENG format works, so I tried several things:
- Put "yyyy-MM-dd" into the filter, return always false which isn't true because there should have some matches
- Make 3 variables, transforming my dates into a string with the following pattern "yyyy-MM-dd" and then into a date again => Return false every time.
So I will check again to see if I'm not mistaken about the matches that should be here, but in the meantime, if you have some ideas or experience this before, please help me. Smiley Embarassed
One Star

Re: compareDate does not work at all

Hello,
are you using the compare date function?
Seventeen Stars

Re: compareDate does not work at all

If you provide a date as String in the format ddMMyyyy yes indeed Talend compares the String starting with the first char but your idea about the way Talend compares Date objects is - please don't be angry - nonsense.
In a tMap the joins the both objects (main column and lookup column) will be check by the equals method of the objects. The pattern in the schema definition for date types will only be used if you convert the date implicit into a string (e.g. you print it out with tLogRow or you get a string from the source and want have it as Date).
It would be great to see your schema definition and you attempts to join it in the tMap.
Moderator

Re: compareDate does not work at all

Hi bbernard,
It seems you have resolved it in the Forum compareDate does not work at all. Could you please also set the topic as resolved?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.