Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hello community,
in my csv file i have three different date formats -> ("MM/dd/yyyy", "MM.dd.yyyy", "yyyy") as string values.
I wanted to use parsedate function in tMap.
First i did it like this: TalendDate.parseDate("MM.dd.yyyy",row1.birth_date);
and it works for one or more rows when it is only THIS format.
But as mentioned before I also need TalendDate.parseDate("MM/dd/yyyy",row1.birth_date); and
TalendDate.parseDate("yyyy",row1.birth_date);
How can I combine these three types? I tried to use +, && but it does not work.
Can someone help me out?
thanks in advance
lisua
Hi Lisua,
When we have multiple date formats on the same column, we should validate the date value by using isdate before parsing it to date .
!Relational.ISNULL(row1.birth_date)?
(TalendDate.isDate(row1.birth_date,"MM/dd/yyyy")?
TalendDate.parseDate("MM/dd/yyyy",row1.birth_date):
TalendDate.isDate(row1.birth_date,"MM.dd.yyyy")?
TalendDate.parseDate("MM.dd.yyyy",row1.birth_date):
TalendDate.isDate(row1.birth_date,"yyyy")?
TalendDate.parseDate("yyyy",row1.birth_date): null
):null
This logic will solve your problem.
If the answer has helped you, could you please mark the topic as resolved.
Hi Lisua,
When we have multiple date formats on the same column, we should validate the date value by using isdate before parsing it to date .
!Relational.ISNULL(row1.birth_date)?
(TalendDate.isDate(row1.birth_date,"MM/dd/yyyy")?
TalendDate.parseDate("MM/dd/yyyy",row1.birth_date):
TalendDate.isDate(row1.birth_date,"MM.dd.yyyy")?
TalendDate.parseDate("MM.dd.yyyy",row1.birth_date):
TalendDate.isDate(row1.birth_date,"yyyy")?
TalendDate.parseDate("yyyy",row1.birth_date): null
):null
This logic will solve your problem.
If the answer has helped you, could you please mark the topic as resolved.