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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Compare two dates with the result days

Hello all, 

I need to do this in talend: 

IF (delay_date > now()) THEN (delay_date - now()) ELSE 0

what I have done was:

TalendDate.compareDate(TalendDate.parseDate("yyyy-MM-dd",row1.delay_date))>0 ? TalendDate.diffDate(TalendDate.parseDate("yyyy-MM-dd",row1.delay_date) TalendDate.getCurrentDate(),"dd"):'0'

 

but is not working, returns this error: Detail Message: The method getCurrentDate() is undefined for the type Date

 

Anyone can help me on this?

 

Thanks 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I have changed the single quotes to double quotes and it works.

thanks,

 

Solution:

(Integer.parseInt(row1.delay_date)<0)?"00":
((Integer.parseInt(row1.delay_date)>99)?"99":row1.delay_date)

View solution in original post

9 Replies
Anonymous
Not applicable
Author

Now I have this:

TalendDate.compareDate(TalendDate.getCurrentDate(),TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",row1.delay_date))>0? TalendDate.diffDate(TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",row1.delay_date), TalendDate.getCurrentDate(),"dd"):'0'

 

but still not working.

 

Help! 

Anonymous
Not applicable
Author

this is another try, but still no working.

 

TalendDate.compareDate(TalendDate.getCurrentDate(),TalendDate.parseDate("yyyy-MM-dd",row1.delay_date))>0? TalendDate.addDate(TalendDate.parseDate("yyyy-MM-dd",row1.delay_date),"yyyy-MM-dd", -TalendDate.getCurrentDate(),"dd"):'0'

manodwhb
Champion II
Champion II

@esilva , What is the output data type of the filed?

Anonymous
Not applicable
Author

The datatype of the output is string

Anonymous
Not applicable
Author

Another :

 

TalendDate.compareDate(TalendDate.getCurrentDate(),TalendDate.parseDate("yyyy-MM-dd",row1.delay_date))>0? String.valueOf(TalendDate.diffDate(TalendDate.parseDate("yyyy-MM-dd",row1.delay_date),TalendDate.getCurrentDate(),"dd")):'0'

 

not working also, But I think i'm close

Anonymous
Not applicable
Author

Hi,

 

   What is the business objective you are trying to achieve? Could you please explain with 1-2 sample input records and expected output records?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Anonymous
Not applicable
Author

The specification has changed.

Thanks.

 

now I have to validate this:

If this value is <0 then '00'
if this value > 99 then '99'

then value

 

but the value is a string.

 

what I have is: 

 

(Integer.parseInt(row1.value)<0)?'00'0683p000009MPcz.png(Integer.parseInt(row1.value)>99)?'99':row1.value)

 

but is not working. 

 

 

 

Anonymous
Not applicable
Author

I have changed the single quotes to double quotes and it works.

thanks,

 

Solution:

(Integer.parseInt(row1.delay_date)<0)?"00":
((Integer.parseInt(row1.delay_date)>99)?"99":row1.delay_date)

manodwhb
Champion II
Champion II

@esilva ,try the below one is working for me that.

 

row1.newColumn==null || row1.newColumn.equals("")?null 0683p000009MPcz.pngInteger.parseInt(row1.newColumn )<0?"00"0683p000009MPcz.pngInteger.parseInt(row1.newColumn )>99?"99":row1.newColumn))