Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there,
I am a newbie to talend. I want to ask you, how to do this item 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.
Thank you in advance for helping me.
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 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.