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: 
_AnonymousUser
Specialist III
Specialist III

Date comparison in Tmap fails

I have two dates, one coming from source and other one from Global.
from source is srce.code_desc_event_date which is string in the format 20131231 and
from global is srce_max_date in date format.
Business rule: Build filter to pass If Global date is NULL or Source Date is >= Global date.
I have following code written but it fails, any help would be greatly appreciated.
((String)globalMap.get("srce_max_date")) == null ||
(TalendDate.parseDate("dd-MM-yyyy",
TalendDate.formatDate("dd-MM-yyyy", TalendDate.parseDate("MM/dd/yyyy",srce.code_desc_event_date)))
.equals((Date)globalMap.get("srce_max_date"))
||
TalendDate.parseDate("MM/dd/yyyy",srce.code_desc_event_date).after((Date)globalMap.get("srce_max_date"))
)

thanks in advance.. happy Talend programming to all.
!John
Labels (2)
1 Reply
Anonymous
Not applicable

I guess the value srce_max_date is a Date type object.
(globalMap.get("srce_max_date")) == null || 
TalendDate.parseDate("yyyyMMdd", srce.code_desc_event_date).before((Date) globalMap.get("srce_max_date")) == false
)

First of all, why do you do not use the format your string get yyyyMMdd and struggle with a lot of converts (all wrong)?
Instead of asking equals or after you could simply ask: not before.