Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
idembel2
Creator
Creator

TalendDateCompareDate function

Hi All,

 

I do a small job to test my inputs with TalendDate.compareDate function, but i am not satisfied to result.

Find bellow screenshot of tMap and also tlogRow output.

0683p000009M2VT.png

 

.---------+----------+--------------+--------------------+----------------------.
|                                   tLogRow_4                                   |
|=--------+----------+--------------+--------------------+---------------------=|
|ID       |SourceDate|Dateplus30days|comparetoCurrentDate|comparetoCurrentDate_2|
|=--------+----------+--------------+--------------------+---------------------=|
|SF1081014|30/11/2018|30-12-2018    |1                   |Y                     |
|SF1016028|30/11/2018|30-12-2018    |1                   |Y                     |
|SF1017008|21/12/2018|20-01-2019    |-1                  |N                     |
|SF1017109|23/11/2018|23-12-2018    |1                   |Y                     |
|SF1017148|28/11/2020|28-12-2020    |1                   |Y                     |
|SF1017159|23/11/2018|23-12-2018    |1                   |Y                     |
|SF1017197|20/12/2018|19-01-2019    |-1                  |N                     |
|SF1017228|30/11/2018|30-12-2018    |1                   |Y                     |
|SF1018052|23/11/2018|23-12-2018    |1                   |Y                     |
|SF1018187|30/11/2018|30-12-2018    |1                   |Y                     |
|SF1018239|30/11/2018|30-12-2018    |1                   |Y                     |
'---------+----------+--------------+--------------------+----------------------'

Culumns : ID, SourceDateDateplus30days are correct

But i don't why column comparetoCurrentDate and comparetoCurrentDate_2 are not correct

 

These are my expressions:

comparetoCurrentDate

TalendDate.compareDate(TalendDate.addDate(row2.SourceDate,30,"dd") , TalendDate.getCurrentDate() , "dd/MM/yyyy" )

comparetoCurrentDate_2

row2.SourceDate != null &&  TalendDate.compareDate(TalendDate.addDate(row2.SourceDate,30,"dd") , TalendDate.getCurrentDate()  , "dd/MM/yyyy" ) < 0 ? "N" : "Y" 

May somebody explain why or what wrong 

 

Thank you in advanced

Labels (3)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

TalendDate.compareDate with Pattern does the string comparison of Date. It is recommended to use it only one part of date like Date or Month Or Year etc.

Otherwise you can do this w/o Pattern or convert your Date format before passed to the function. like
TalendDate.compareDate(TalendDate.addDate(row2.SourceDate,30,"dd") , TalendDate.getDate("dd/MM/yyyy" ))

View solution in original post

2 Replies
akumar2301
Specialist II
Specialist II

TalendDate.compareDate with Pattern does the string comparison of Date. It is recommended to use it only one part of date like Date or Month Or Year etc.

Otherwise you can do this w/o Pattern or convert your Date format before passed to the function. like
TalendDate.compareDate(TalendDate.addDate(row2.SourceDate,30,"dd") , TalendDate.getDate("dd/MM/yyyy" ))

idembel2
Creator
Creator
Author

Hi akular2301,

 

Thank you for your reply, i implement it and it works.

Bellow my expression

TalendDate.compareDate(TalendDate.addDate(row2.SourceDate,30,"dd") , TalendDate.parseDate("dd/MM/yyyy",TalendDate.getDate("dd/MM/yyyy")))