Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
mks02
Creator
Creator

Check date in a particular date range using tmap filter

How do I check if a Date exists within a specific date range?

I am joining a pipeline which comes from jdbcInput--> tmap1--> tMap_join -->tOutputExcel
For tMap_Join : I am joining a SQL DB table with tMap1 out result. all dates column are in 'yyyy-MM-dd' format.

I need to check : tmap1.st_dat  >= sqlTable.st_dat AND tmap1.end_dat  <= sqlTable.end_dat

in tmap_join filter area.

 

How do i achieve this??
Attaching screenshot for this.

Labels (3)
1 Solution

Accepted Solutions
mks02
Creator
Creator
Author

I have check the data and write condition below for this:
(TalendDate.compareDate(tmap1.st_dat, sqlTable.st_dat ==1 || TalendDate.compareDate((tmap1.st_dat, sqlTable.st_dat) ==0) &&
(TalendDate.compareDate(tmap1.end_dat, sqlTable.end_dat) ==-1 || TalendDate.compareDate((tmap1.end_dat, sqlTable.end_dat)) ==0)

 

We can understand TalendDate.compareDate by this :
Date1 < Date2   :  Returns -1
Date1 = Date2   :  Returns 0
Date1 > Date2   :  Returns 1

 

Above condition works for me.

View solution in original post

5 Replies
Anonymous
Not applicable

Hello,

Could you please elaborate your case with an example with input and expected output values?

Best regards

Sabrina

mks02
Creator
Creator
Author

I have check the data and write condition below for this:
(TalendDate.compareDate(tmap1.st_dat, sqlTable.st_dat ==1 || TalendDate.compareDate((tmap1.st_dat, sqlTable.st_dat) ==0) &&
(TalendDate.compareDate(tmap1.end_dat, sqlTable.end_dat) ==-1 || TalendDate.compareDate((tmap1.end_dat, sqlTable.end_dat)) ==0)

 

We can understand TalendDate.compareDate by this :
Date1 < Date2   :  Returns -1
Date1 = Date2   :  Returns 0
Date1 > Date2   :  Returns 1

 

Above condition works for me.

Anonymous
Not applicable

How to filter date something like -- if today == Monday then filter from current date - 2 days (Sat and Sun) else filter date from current date

manodwhb
Champion II
Champion II

@ADee,you need to use the below way.

 

TalendDate.getPartOfDate("DAY_OF_WEEK",TalendDate.parseDate("dd-MM-yyyy HH:mm:ss", "13-10-2010 12:23:45"))==2 ?TalendDate.addDate(TalendDate.getCurrentDate() ,-1,"dd") :TalendDate.getCurrentDate()

Anonymous
Not applicable

@manodwhb Thanks for the help however how would this help in terms of range filter in Date?

as we have not mentioned any range like BETWEEN query!

 

Example

I have set of records

12-01-2018

12-02-2018

12-03-2018

12-04-2018

If I run my job today (Monday) output should have 3 records 

12-01-2018

12-02-2018

12-03-2018

if i run it tomorrow then the output will be 12-04-2018