Five Stars

Make tMap remove a date 00/00/00

Hello


I have a csv file which have some time a date like this 00/00/00 by using tMap I want to make a condition if it 00/00/00 make it null 

I tried but its not work

 

ToMap.date_naissance  != "00/00/00" ? (ToMap.date_naissance).toString() : null 

 

Thank you

  • Data Integration
3 REPLIES
Seven Stars TRF
Seven Stars

Re: Make tMap remove a date 00/00/00

As input is a csv file, you should consider date_naissance field as a string. Change it in the corresponding schema and try this:

ToMap.date_naissance.equals("00/00/00") ? null : date_naissance

For France it should be dd/MM/yy.

Hope this helps,

TRF
Six Stars

Re: Make tMap remove a date 00/00/00

Hi,

It works "ToMap.date_naissance.equals("00/00/00") ? null : date_naissance" Only when both the source and target data type is string.

What if our datatype in source is string and target is date data type.

Seven Stars TRF
Seven Stars

Re: Make tMap remove a date 00/00/00

As I suggest, you should have the date as a string as it comes from a csv file.
For the initial request, I don't think casting "00/00/00" is possible as it is not a valid date.
In other case, if one of the dates is a string you need to convert it for comparison:
TalendDate.parseDate("yy/MM/dd", row1.stringField)

Have look at this link for information about TalendDate routines.
https://help.talend.com/display/TalendOpenStudioforBigDataUserGuide520EN/10.5+TalendDate+Routines

TRF