Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey!
Can someone please how to conduct an else if function while comparing 2 variables? Eg: 'If beginningdate < endingdate, write T or else write F.
Please note, I don't want to compare a any variable with an integer, but I want to compare actual two variables present in my schema.
the operator < does not work with string type, you need to convert string data to Date,
TalendDate.parseDate("yyyy-MM-dd",row1.beginningdate).getTime()<TalendDate.parseDate("yyyy-MM-dd", row1.endingdate).getTime()?"T":"F"
//"yyyy-MM-dd" is the date pattern, change it based on your real date format.
if the data type is Date, then you can write the expression like this:
row1.beginningdate.getTime()<row1.endingdate.getTime()?"T":"F"
The data type is string in my case.
the operator < does not work with string type, you need to convert string data to Date,
TalendDate.parseDate("yyyy-MM-dd",row1.beginningdate).getTime()<TalendDate.parseDate("yyyy-MM-dd", row1.endingdate).getTime()?"T":"F"
//"yyyy-MM-dd" is the date pattern, change it based on your real date format.
Worked great. Thankyou!
Hello REjaz1662272866,
a solution (without .getTime()) might be:
TalendDate.compareDate(TalendDate.parseDate("yyyy-MM-dd", row1.beginningDate), TalendDate.parseDate("yyyy-MM-dd", row1.endingDate)) < 0 ? "T" : "F"
Best regards,
Thomas