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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
azrylln
Contributor
Contributor

IF with isdate checking

Hi there,

 

  I am a newbie to talend. I want to ask you, how to do this item below:

 

  •     I want to check the validity of a given date from an input table. If the date is a valid date, then the date will be inserted to output table. if it is not a valid date, then space will be inserted to the column. Both the input and output column are date field and my codes are as below:

     TalendDate.isDate(TalendDate.formatDate("dd-MM-yyyy",row1.birthdate),"dd-MM-yyyy")?row1.birthdate:""

 

    when rebuilding, i got this compilation error: >> Type mismatch: cannot convert from String to Date

    please help me to solve this issue.

 

  • I am also open to ideas on how to make this process easier using Talend.

 

Thank you in advance for helping me.

Labels (2)
4 Replies
Anonymous
Not applicable

I suspect that the data type of the row1.birthdate column is String and not Date. The formatDate method requires as Date. All you need to do is this....

 

  TalendDate.isDate(row1.birthdate,"dd-MM-yyyy")?row1.birthdate:""

Of course, your row1.birthdate column will need to hold the date in "dd-MM-yyyy" format. I'd advise adding a tLogRow before the component you are using this logic in, so that you can see what the date format is of your String.

aashish_21nov
Creator
Creator

Hi @azrylln

 

you getting this error due to formatDate function which return string data type  accept only Date type value. So as @rhall suggest you can use isDate function directly with your birthdate or if your date is in different pattern use parseDate function.

 

 

Anonymous
Not applicable


@aashish wrote:

Hi @azrylln

 

you getting this error due to formatDate function which return string data type and isDate function accept only Date type value. So as @rhall suggest you can use isDate function directly with your birthdate or if your date is in different pattern use parseDate function.

 

 


This is not true. The isDate method requires two Strings (stringDate and pattern). There is absolutely no point to the isDate method if it accepts a Date object. A Date object is a Date or null.

aashish_21nov
Creator
Creator

yeah @rhali its typo