• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » type mismatch : cannot convert from string to date

#1 2011-05-26 10:54:14

nilesh
Member
Company: IP Creations Pvt Ltd
Registered: 2010-12-31
Posts: 50

type mismatch : cannot convert from string to date

hello,

       i need to set  previous day date to fetch my previous day status records so i used this code .
     
        " TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(), - 1, "dd")) "

by this code im getting previous day date but only in "string" format in stage variables but i want it in "date" format

   if i changed that to "date" format it shows error like " type mismatch : cannot convert from string to date " .

how can i get the same in "date" format ? can anyone suggest me for this?


Thanks in advance
   Nilesh


Thanks In Advance ,
       Nilesh R

Offline

#2 2011-05-26 10:59:34

nilesh
Member
Company: IP Creations Pvt Ltd
Registered: 2010-12-31
Posts: 50

Re: type mismatch : cannot convert from string to date

can anyone help me for this issue asap?


Thanks In Advance ,
       Nilesh R

Offline

#3 2011-05-26 11:03:31

shong
Talend team
Registered: 2007-08-29
Posts: 10299
Website

Re: type mismatch : cannot convert from string to date

Hi
The method formatDate returns a String, if want a date format,  use this expression:
TalendDate.addDate(TalendDate.getCurrentDate(), - 1, "dd")

Best regards
Shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#4 2011-05-26 11:31:17

nilesh
Member
Company: IP Creations Pvt Ltd
Registered: 2010-12-31
Posts: 50

Re: type mismatch : cannot convert from string to date

for that im getting like

"Wed May 25 14:58:56 GMT+05:30 2011"

but i need a output like "2011-05-25" in date format.


Thanks In Advance ,
       Nilesh R

Offline

#5 2011-05-26 11:47:12

shong
Talend team
Registered: 2007-08-29
Posts: 10299
Website

Re: type mismatch : cannot convert from string to date

Hi
Change the data type of column on schema to String, then you are able to use the expression as below to formate a Date to a String.
TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(), - 1, "dd"))

Best regards
Shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#6 2011-05-26 12:04:05

nilesh
Member
Company: IP Creations Pvt Ltd
Registered: 2010-12-31
Posts: 50

Re: type mismatch : cannot convert from string to date

Ya this is what i used earlier .
now i need the same result(2011-05-18) but the datatype should be in date format because i need to merge it with my data which is in "date" datatype ..

Is "2011-05-18" format  in "date" data type in talend tool....


Thanks In Advance ,
       Nilesh R

Offline

#7 2011-05-26 12:35:14

shong
Talend team
Registered: 2007-08-29
Posts: 10299
Website

Re: type mismatch : cannot convert from string to date

Hi

Is "2011-05-18" format  in "date" data type in talend tool....

Yes, just set the date pattern as "yyyy-MM-dd",  it will looks like "2011-05-18" in target.

Best regards
Shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#8 2011-05-26 13:28:13

nilesh
Member
Company: IP Creations Pvt Ltd
Registered: 2010-12-31
Posts: 50

Re: type mismatch : cannot convert from string to date

yes i can change the format but if the data type is "date" it showing the same type mismatch error.


Thanks In Advance ,
       Nilesh R

Offline

#9 2011-05-27 10:26:11

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1123

Re: type mismatch : cannot convert from string to date

TalendDate.parseDate

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » type mismatch : cannot convert from string to date

Board footer

Powered by FluxBB