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

Comparing dynamic date with a specific date

Hi,

 

Please advise me below. Thanks

I would like to deliver the report showing ETA>=5/1/2019. Currently ETA is a string data type and date in ETA column has empty value or date format like 5/1/2019, 3/24/2019, 12/13/2017. 

I was trying below syntax but I got Unparseable date error such as "2019-03-12" but I looked at my data and I did not find date like that format.

TalendDate.compareDate(TalendDate.parseDate("MM/dd/yyyy",row1.ETA),TalendDate.parseDate("MM/dd/yyyy","5/1/2019"))>=0 

Labels (2)
2 Replies
nfz11
Creator III
Creator III

Your code worked fine for me with the data you provided.

 

Screenshot of my test job showing the fixed input with your test data:

0683p000009M52s.png

 

Contents of the tJavaRow component:

 

 

int compare = TalendDate.compareDate(TalendDate.parseDate("MM/dd/yyyy",row1.ETA),TalendDate.parseDate("MM/dd/yyyy","5/1/2019"));
System.out.println(row1.ETA + ":" + compare);

Output:

 

Starting job TestDate at 23:55 03/05/2019.

[statistics] connecting to socket on port 3424
[statistics] connected
5/1/2019:0
3/24/2019:-1
12/13/2017:-1
[statistics] disconnected

Job TestDate ended at 23:55 03/05/2019. [exit code=0]

 

You should check your data input to make sure it does not contain that unexpected date value that you showed.

 

I am also attaching the zip archive of the test job.


TestDate.zip
Anonymous
Not applicable
Author

I suspect that somewhere in your data there is a poorly formatted String date. Can you give a screenshot of your job so that it can provide a few clues?