You are not logged in.
Announcement
Unanswered posts
|
Pages: 1
Hi,
I would like to join two files using simple condition "fileA.date between (fileB.datefrom and fileB.dateto)". very simple with sql but how to do that with Talend ?
Example :
File A : contain all the day for a year
dateofday | monthofday |
01-01-2012 | 01
02-01-2012 | 01
03-01/2012 |01
...
File B : contain official holliday period
begindateholliday | enddateholliday | label_hollidays
26-12-2011 | 08-01/2012 | chrismas
What I want to have in output :
dateofday | monthofday | label_hollidays
01-01-2012 | 01 | christmas
02-01-2012 | 01 | christmas
03-01-2012 | 01 | christmas
...
Can I do that with tmap ? If yes, what is the synthax and link to define between my two source files ?
Regards.
Offline
Hi DARWI, you put the join conditions in the filter criteria on the lookup table.
http://www.talendforge.org/forum/viewtopic.php?id=10386
Since you are comparing dates, you would either convert the dates to numeric values which could be compared with arithmetic operators, or use something like this
(DWSTalendDate.compareDate(row1.dateOfDay ,row2.begindateholliday ,"yyyy-MM-dd")>= 0)
&&
(DWSTalendDate.compareDate(row1.dateOfDay ,row2.enddateholliday ,"yyyy-MM-dd")< 0)
Depending on you data, you may want to add a tUniqRow after the tMap.
Thanks,
Ben
Offline
Pages: 1