Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
muralam
Creator
Creator

Compare two dates

hi Team,

 

i wanted to compare two date columns coming from two tables 

i used TalendDate.compareDate(date1,date2) != 0 as it is returning an integer value this is not expected result

getting null pointer exception in tmap, please help on it.

 

Regards,

Meena

 

Labels (2)
23 Replies
muralam
Creator
Creator
Author

Hi All,

Now am not getting the error null pointer exception, but am not able to compare date columns properly

i have written the logic as below, the attached screen shot, am comparing two tables on below date columns which can be null, if result set is false like null!=datevalue i have to update my target table with date

 

out.DEV_INT_BIRTH_DATE!= null && row1.DEV_INT_BIRTH_DATE != null ?(TalendDate.compareDate(out.DEV_INT_BIRTH_DATE,row1.DEV_INT_BIRTH_DATE)==0 ?false : true) :true 

 

Regards,

Meena


Capture.PNG
Anonymous
Not applicable

It depends on if it's a primitive type or not. You have to use Integer.equalsTo(Integer) if its an Integer type. "==" is for a primitive type of int.

Anonymous
Not applicable

Integer.intValue() == 0. In all these cases Integer is your comparison result.

muralam
Creator
Creator
Author

But these are date columns I didn't get your input compare integer
Anonymous
Not applicable

Can you show your whole tMap please? I believe your problem is with your configuration, but I can't tell unless I can see your whole tMap. By the way, there is no need for you to write the code you have included above. This code...

TalendDate.compareDate(out.DEV_INT_BIRTH_DATE,row1.DEV_INT_BIRTH_DATE)==0

....will return true if the columns match (even if both are null....which is possibly where your problem arrises) or false if they do not. Nulls are handled here. This is all you require for your logic as to whether an update is required. If you can read Java, take a look at the routine yourself. I have posted the code in a message above.

muralam
Creator
Creator
Author

@rhall
yes i have to handle nulls, may be i have to compare
null=datevalue
null=null
null=empty, when i compare as these are nullable columns, nulls are expected, which i am not getting the result as expected,
my expected result i wanted to compare null=date load date value, null=null,null=emptyfield load nothing pass null, finally i wanted to pass data when there is a date value or else null, kindly help me out.
muralam
Creator
Creator
Author

The same above mentioned scenario i am able to load data in case of strings where i have written a small routine to compare the required columns to find updates

 

@rhall, i have given complete tmap settings

 

Regards,

Meena


tmap settings.PNG
muralam
Creator
Creator
Author

Hi,

 

Any update on the below request, as it is little urgent

 

Regards,

Meenas

manodwhb
Champion II
Champion II

@muralam,please findthe attahced smaple job to compare dates.


test_date.zip
Anonymous
Not applicable

OK, please consider this as FACT, not fake news. This method will work and take into consideration nulls as well as dates.....

TalendDate.compareDate(out.DEV_INT_BIRTH_DATE,row1.DEV_INT_BIRTH_DATE)==0

 So, if your values are null and null, it will return 0. If your dates are the same (down to the millisecond) it will return 0. If your dates are different or one is a null, then it will return either 1 or -1 depending on which date is null or greater.

 

If you are getting a nullpointerexception I guarantee that it is NOT to do with this method. This is just confusing the issue. 

 

Can you please take a screenshot of your whole tMap. NOT small sections. I need to see ALL of it. Can you also add a tLogRow before the tMap (for both inputs, Main and Lookup) and post the data here so that we can see what is going into your tMap? You will also get an error message with the nullpointerexception. Can you post the exact error.