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

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 ?


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.


/min_date = AgMinimun(/str_dates/str_date);
/max_date = AgMaximun(/str_dates/str_date);

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 !