Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi have XML field that I am extracting as one field and has timestamp of format (yyyy-MM-dd'T'HH:mm:ss.SSSSSS).
Now I want to only get yyyy-MM-dd for the date comparison so that I can do the incremental load like ( yyy-MM-dd)<= 7 (for 7 days incremental).
On my tjava I have:
context.runDate=TalendDate.parseDate("yyyy-MM-dd","2017-07-03")
On the tMap, Expression builder I have to change the format of the timestamp to yyyy-MM-dd :
TalendDate.parseDate("yyyy-MM-dd",TalendDate.formatDate("yyyy-MM-dd",TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss.SSSSSS",row2.timeStamp)))
Then I have below logic for date compare:
(TalendDate.compareDate(Var.datevalue,context.runDate,"yyyy-MM-dd"))<=1
When I run the job it runs fine but it doesn't load as logic but will load the entire data.
Can somebody please help me on this.
Hi,
Do you mean your expression is not working on row2.timeStamp? Did you use your expression in expression filter or expression field?
Best regards
Sabrina
Hello Brawal,
I think there is a problem in your expression :
(TalendDate.compareDate(Var.datevalue,context.runDate,"yyyy-MM-dd"))<=1
Because the method 'compareDate' in Talend accepts the values :
• CompareDate returns 0 if d1 = d2
• CompareDate returns 1 if d1 > d2
• CompareDate returns -1 if d1 < d2
In your case, your expression is allways true, that's why it loads the entire data.
Try this :
(TalendDate.compareDate(Var.datevalue,context.runDate,"yyyy-MM-dd"))<1
I hope this answer will help you.
TD
Thanks you for that correction. I see now data is not loaded at all. Is the logic wrong? If so can somebody please suggest me the fix?
Hi,
Do you mean your expression is not working on row2.timeStamp? Did you use your expression in expression filter or expression field?
Best regards
Sabrina
Sorry I found a solution to this. Thanks for all the replies. Really appreciated.
Hello,
Thanks for your feedback.Would you mind sharing your solution on forum?
Best regards
Sabrina