Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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)
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!
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'
@esilva , What is the output data type of the filed?
The datatype of the output is string
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
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
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'(Integer.parseInt(row1.value)>99)?'99':row1.value)
but is not working.
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)
@esilva ,try the below one is working for me that.
row1.newColumn==null || row1.newColumn.equals("")?null Integer.parseInt(row1.newColumn )<0?"00"
Integer.parseInt(row1.newColumn )>99?"99":row1.newColumn))