Can anyone please advise me below issue? Thanks a lot! -
My purpose was to compare if "ETD" is later than "ETA Port" in string data type
I changed my schema to show "string" for two dates, and then I wrote syntax - ETD.compareTo(ETA_to_Discharge_Port)>0
I think my syntax is correct to compare two strings (please correct me if I am wrong) and then I got below output which ETD is earlier than ETA Port
Hello @szhou1 ,
Quite new here but if I can try to help : Did you try to use TalendDate.compareDate() & FormatDate() ?
Check here : https://help.talend.com/reader/~R4Lk_SlELw9a8pKBKTm9A/JFWl8U3lEbhWZEFAUtYvMw
Hi, I think you can not compare to dates in string format. May be you can use variable ports in tMap to convert input string to date temporarily and compare dates. for output you can use input string values.
I changed into "date" data type and used syntax - TalendDate.compareDate(BKGerrors.ETD, BKGerrors.ETA_to_Discharge_Port)>0
and I got below output -
I checked the source data and find that the output is incorrect because the source for ETD should be below
not sure why I got 5/2/2019 which is totally different from the source
Thank you for the help!
Can you please explain in detail why you use tfixrowinput? I am new on Talend so not quite understand...
The flow I build is below
After I change my syntax to TalendDate.compareDate(Var.var1,Var.var2)>0 I still get below errors -
I filtered out the empty data and I don't have issue for parse date error for now.
but I have other issue - the output I want is data with ETD>ETA
For now no matter what I change equation I got ETD<ETA (var1 is ETA and var2 is ETD)
Try the following:
if first one less than second one return number -1 (Var.ETA_Date<Var.ETD_Date)
equal's return number 0 (Var.ETA_Date=Var.ETD_Date)
bigger than return number 1. (Var.ETA_Date>Var.ETD_Date)
@szhou1,you were getting empty value in date coumn,since you were not able to convert.
can you cehck with below expressions in Variable.
"".equals(row1.EDT) || row1.EDT == null ? "" : TalendDate.parseDate("mm/DD/yyyy",row1.EDT))
"".equals(row1.ETA) || row1.ETA == null ? "" : TalendDate.parseDate("mm/DD/yyyy",row1.ETA))
Talend named a Leader.
Kickstart your first data integration and ETL projects.
Watch the recorded webinar!
Learn how to do cool things with Context Variables
Find out how to migrate from one database to another using the Dynamic schema
Pick up some tips and tricks with Context Variables