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

Output Wrong when compare two dates with string format in Tmap

Hi,

 

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

0683p000009LxH7.png

Labels (2)
18 Replies
daez
Creator
Creator

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

 

Cheers

Anonymous
Not applicable
Author

Thank you for your help!
I input string data type for two dates so I did not use "compareDate()" syntax because this will need "Date"data type
If I change my input dates to "Date" data type, it will cause issue because my input Excel reports include lot of different date format
vboppudi
Partner - Creator III
Partner - Creator III

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.

 

Regards,

Anonymous
Not applicable
Author

Hi,

 

I changed into "date" data type and used syntax - TalendDate.compareDate(BKGerrors.ETD, BKGerrors.ETA_to_Discharge_Port)>0

and I got below output - 

0683p000009LxZe.png

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
0683p000009LxLo.png

manodwhb
Champion II
Champion II

You need to convert string to date both column values in same format.and then you need to compare.
Anonymous
Not applicable
Author

Hi,

I created variable to convert string to date and compare. and I got below errors -

0683p000009LxaN.png

0683p000009Lx4E.png

vboppudi
Partner - Creator III
Partner - Creator III

Please try below

0683p000009LxGs.png0683p000009LxaO.png

From the source 4th record rejected because of ETD>ETA.

Regards,

Anonymous
Not applicable
Author

Hi,

 

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

0683p000009LxTs.png

vboppudi
Partner - Creator III
Partner - Creator III

tFixedFlowInput used to create sample data.

 

Regards,