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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Comparing Dates in tMap

Hi All,
I have been trying to figure out why my tMap isn't comparing dates properly.
I have created a globalmap string called "testDate" and set it to "04/03/13" ("mm/dd/yy" format). This is using tSetGlobalVar
I am then reading a table from an Oracle db that has 3 fields: User ID (integer), Login (String), and LoginDate (Date)
The tOracleInput then goes to a tMap for processing.
The goal is to get all users whose LoginDate matches the global "testDate"
This is my tMap filter condition: TalendDate.compareDate(row1.LAST_LOGIN_DATE,TalendDate.parseDate("mm/dd/yy",(String)globalMap.get("testDate"))) == 0
Basically I am parsing the the global testDate as TalendDate and then comparing that to the row date from Oracle.
My filter returns 0 results even though there are users whose login date match the criteria.
Any help would be amazing, thank you so much!
I am attaching images of my job, it is quite simple.
Here is some sample data from the tLogRow when I remove the filter condition in the tMap:
15419|user1|20-11-12
15574|user2|13-06-12
15580|user3|02-10-12
15593|user4|26-06-12
15608|user5|06-11-12
0683p000009MEH7.jpg 0683p000009MEHC.jpg 0683p000009MEGU.jpg 0683p000009MEHH.jpg
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi, that one change did not fix it, however, it led me on the path to the solution.
I found that there is a second TalendDate.compareDate that lets you specify which parts of the date to compare, so it worked when I changed my expression to: TalendDate.compareDate(row1.LAST_LOGIN_DATE,TalendDate.parseDate("mm/dd/yy",(String)globalMap.get("testDate")),"dd-MM-yyy") == 0
Thanks for the assistance shong!

View solution in original post

3 Replies
Anonymous
Not applicable
Author

Is the potential issue that I'm comparing row1.LAST_LOGIN_DATE which is of type Date with the result of a parseDate ?
Anonymous
Not applicable
Author

Hi
This is my tMap filter condition: TalendDate.compareDate(row1.LAST_LOGIN_DATE,TalendDate.parseDate("mm/dd/yy",(String)globalMap.get("testDate"))) == 0

The date pattern should be "MM/dd/yy", MM presents month in a year, welll mm means minutes in a hour.
Shong
Anonymous
Not applicable
Author

Hi, that one change did not fix it, however, it led me on the path to the solution.
I found that there is a second TalendDate.compareDate that lets you specify which parts of the date to compare, so it worked when I changed my expression to: TalendDate.compareDate(row1.LAST_LOGIN_DATE,TalendDate.parseDate("mm/dd/yy",(String)globalMap.get("testDate")),"dd-MM-yyy") == 0
Thanks for the assistance shong!