Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Ankit_DS
Contributor II
Contributor II

Type Mismatch - Cannot covert String to Date

I am trying to get system generated current date and push into a target table column (Please note - date is not coming from source but created a part of expression in tMap)

I am able to understand the error and hypothetically know its solution, but nothing seems to work. the target table accept date in DATE datatype. however, below expression in Talend creates date in string DATATYPE.

TalendDate.formatDate("MM-dd-yyyy",TalendDate.getCurrentDate()) 

as you see below, it gives error, however when i test, it gives proper date. I have also used several flavors of TalendDate.parseDate("MM-dd-yyyy",[fed the above expression here] but this too didnt work.)

0695b00000N3lFkAAJ.png

0695b00000N3lFpAAJ.png

Labels (3)
1 Solution

Accepted Solutions
Ankit_DS
Contributor II
Contributor II
Author

I am posting the answer myself, problem was, when i was Testing the currentDate function as shown below, it was giving me String format as (SunFeb 06 19:51 EST...), however i just ignored it and went away by writing it in SQLServer target column, and the map ran fine, and in the target table date was showing fine in dd-MM-yyyy format,

 

0695b00000O9wXWAAZ.png 

beware, the format date function, shows the date in dd-MM-yyyy format, but thats actually string and it won't work.

 

0695b00000O9wbOAAR.png

View solution in original post

4 Replies
gjeremy1617088143
Creator III
Creator III

Hi, TalendDate.formatDate return a String and you want a Date. So just use TalendDate.getCurrentDate() wich return a DATE

or if you want a specific date use for eg : TalendDate.parseDate("dd-MM-yyyy","31-01-2022")

Send me love and kudos

Ankit_DS
Contributor II
Contributor II
Author

@guenneguez jeremy​ both these commands dont give date in date datatype.

 

TalendDate.getCurrentDate() --> gives result in string data type.

 

TalendDate.parseDate("dd-MM-yyyy",TalendDate.getCurrentDate()) --> this too didn't work.

Ankit_DS
Contributor II
Contributor II
Author

I am posting the answer myself, problem was, when i was Testing the currentDate function as shown below, it was giving me String format as (SunFeb 06 19:51 EST...), however i just ignored it and went away by writing it in SQLServer target column, and the map ran fine, and in the target table date was showing fine in dd-MM-yyyy format,

 

0695b00000O9wXWAAZ.png 

beware, the format date function, shows the date in dd-MM-yyyy format, but thats actually string and it won't work.

 

0695b00000O9wbOAAR.png

gjeremy1617088143
Creator III
Creator III

TalendDate.getCurrentDate() return date,

TalendDate.parseDate("dd-MM-yyyy","31-01-2022") return date,

TalendDate.formatDate("dd-MM-yyyy",TalendDate.getCurrentDate()) return String