[resolved] compareDate does not work at all

Highlighted
One Star

[resolved] 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 experienced this before, please help me. Smiley Embarassed

Accepted Solutions
One Star

Re: [resolved] compareDate does not work at all

First of all, it was because of my data, it's 100% normal that I got false everytime, because my dates were in 2014 and my mainDate in 2013. Sorry for that.
However I discover this (which I didn't know and not very clear in the documentation imo):
The pattern that you chose when using compareDate is VERY important:
"dd-MM-yyyy" will compare the day FIRST, with this pattern "05-10-2014 < 10-02-2002" will be true.
"yyyy-MM-dd" works fine to compare dates the usual way.

All Replies
One Star

Re: [resolved] compareDate does not work at all

First of all, it was because of my data, it's 100% normal that I got false everytime, because my dates were in 2014 and my mainDate in 2013. Sorry for that.
However I discover this (which I didn't know and not very clear in the documentation imo):
The pattern that you chose when using compareDate is VERY important:
"dd-MM-yyyy" will compare the day FIRST, with this pattern "05-10-2014 < 10-02-2002" will be true.
"yyyy-MM-dd" works fine to compare dates the usual way.

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch