Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
desanip
Contributor
Contributor

string to Date conversion issue

Hello Talendians, 

 

I am trying to convert a string  type to date type for a column. The source date is 2018-12-04 for example. The target date type is "EEE MMM dd hh:mm:ss:zzz yyyy".

 I tried using the following function in my tmap.

 

row4.account_product_termination_date!=null && row4.account_product_termination_date!=" " ? TalendDate.parseDate("EEE MMM dd hh:mm:ss:zzz yyyy",row4.account_product_termination_date)

 

I see errorSmiley Very Happyetail Message: Syntax error, insert ": Expression" to complete Expression

 

Can someone explain me what i am doing wrong?

Labels (3)
1 Solution

Accepted Solutions
billimmer
Creator III
Creator III

Two things,

 

First, to compare strings in java use: 

 

!row4.account_product_termination_date.equals(" ") 

 

instead of !=

 

Also you need a true and false side to your statement, separated by a colon.  So what to you want to happen if the row4.account_product_termination_date is null?  Return null?

 

row4.account_product_termination_date!=null && !row4.account_product_termination_date.equals(" ")  ? TalendDate.parseDate("EEE MMM dd hh:mm:ss:zzz yyyy",row4.account_product_termination_date) : null

 

 

View solution in original post

2 Replies
billimmer
Creator III
Creator III

Two things,

 

First, to compare strings in java use: 

 

!row4.account_product_termination_date.equals(" ") 

 

instead of !=

 

Also you need a true and false side to your statement, separated by a colon.  So what to you want to happen if the row4.account_product_termination_date is null?  Return null?

 

row4.account_product_termination_date!=null && !row4.account_product_termination_date.equals(" ")  ? TalendDate.parseDate("EEE MMM dd hh:mm:ss:zzz yyyy",row4.account_product_termination_date) : null

 

 

desanip
Contributor
Contributor
Author

@billy Thanks for the explanation and the expression works too. Cheers

 

Thank you Sir.