Talend Data Mapper and Date Handling (Comparison, Max, Min)

Employee

Talend Data Mapper and Date Handling (Comparison, Max, Min)

Hello,
I am trying to use the Talend Data Mapper at a client who wants to parse a loop date element and use the maximum and minimum.
I thought that simply using AgMaximum and AgMinimum functions could do it, but after getting errors and reading online help.
- It seems these functions take as argument (and return) only Decimals.
- Date/Time functions don't convert date to decimal/Integer or the other way around.
Now, I am blocked.
Would you then know a way to get the earliest and latest date in a looping date Element using the Talend Data Mapper ?
If not, if I must use an external XMLMap, would you recommend a way to pass simply the looping element out of the Mapper ?
Thanks,

Employee

Re: Talend Data Mapper and Date Handling (Comparison, Max, Min)

Hi mhassine,
Can you set the input date array as type "String"?
Per my test, AgMinimum/Max can be applied to String loop and can return a String as well.
Example:
Input-->
...

20140301
20130308
20121201
20140131
20140401

...
-->Map-->
/min_date = AgMinimun(/str_dates/str_date);
/max_date = AgMaximun(/str_dates/str_date);
-->Output
...
20121201
20140401
Rgds
Yi
Employee

Re: Talend Data Mapper and Date Handling (Comparison, Max, Min)

Hello Yiliu,
Thanks for the answer, but for me, it doesn't work : I have this kind of error :
14578: Error - The specified value cannot be converted to the specified type. (307) (INPUT)
Reason - Converting: String -> Number Category
Value: 2013-03-28
Map: /LBBW/Maps/Leg_Map.xml - Map Element: in$/ndm_message/message/deal/inst/Anonymous_choice/derivative/Anonymous_choice/swap/pay_side_list/leg/period_list/period/adj_start_date
Line: 647 column: 37
For the record, I use the Data Mapper provided with Talend Platform for Data Services with Big Data 5.4.1.
This solution would however not be very nice since I have to define the XML Schema using a provided XSD file, that I am not supposed to modify.
However, my source dates are already sorted, so maybe is there a way to select the first occurrence and the last one, instead of using the AgMaximum and AgMinimum functions ! I didn't yet find this kind of solution.

Actually, I was trying to do it using Data Mapper but I figured, since I have to put the data in a DB afterwards, I could just send that as is into an tXMLMap, get a DI flow with one line for each date, then use a tAggregateRow, I would have the same result at the end.
However, if there is a solution with Data Mapper I would be glad to get it since it would look very nice to the customer !
Thanks !

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads