Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to parse various date formats

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

Labels (3)
1 Solution

Accepted Solutions
ashif2
Creator II
Creator II

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.

View solution in original post

1 Reply
ashif2
Creator II
Creator II

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.