Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

talend date conversion issue

 

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).

0683p000009Lri2.jpg

 

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

 

0683p000009Lrhd.jpg

 

 

0683p000009LriI.jpg

 

 

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.

 

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

Do you mean your expression is not working on row2.timeStamp? Did you use your expression in expression filter or expression field?

0683p000009LrUB.png

Best regards

Sabrina

View solution in original post

5 Replies
Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

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?

Anonymous
Not applicable
Author

Hi,

Do you mean your expression is not working on row2.timeStamp? Did you use your expression in expression filter or expression field?

0683p000009LrUB.png

Best regards

Sabrina

Anonymous
Not applicable
Author

Sorry I found a solution to this. Thanks for all the replies. Really appreciated.

Anonymous
Not applicable
Author

Hello,

Thanks for your feedback.Would you mind sharing your solution on forum?

Best regards

Sabrina