incremental load tMap help

Six Stars

incremental load tMap help

Hi, I am trying to do the incremental load of XML files. I do have date column on yyyy-MM-dd HH:mm:ss which is row2.updatedtimestamp. On first row I am trying to convert my string type data to date format. On the second row I am trying to get the current time.

On the third row I am doing the date differennce with the my date column (row2.updatedtimestamp) with flag.

But the problem is that I am keep getting error as;

Type mismatch: cannot convert from Date to String.

Could you please let me know what is wrong? I also have shared the screenshot of job

 

ExpressionTypeVariable
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",row2.updatedtimestamp )Dateformat_date
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",TalendDate.getDate("yyyy-MM-dd HH:mm:ss"))DateCurrent_date
TalendDate.diffDate(Var.Current_date,Var.format_date,"dd") == 126 ?true:falseBooleanOut_Flag

 

talend tmap date.JPG

Eight Stars sgv
Eight Stars

Re: incremental load tMap help

Hi,

 

What's the complete code executed for the "diff_date" var ??

 

PS : You can activate the Code Mode to see exactly where is the problem !

Six Stars

Re: incremental load tMap help

Sorry forgot to mention that. That error is at   Var.format_date  as the code.

And the complete code to date_diff is as;

Proff_tmp.diff_date = TalendDate

.diffDate(Var.Current_date,

Var.format_date, "dd");

 

 

Eight Stars sgv
Eight Stars

Re: incremental load tMap help

Ok i get it !

Change type of your updatetimestamp column to date type !

 

Good luck

SGV

 

Six Stars

Re: incremental load tMap help

I tried that. It gives following error.

 

The method parseDate(String, String) in the type TalendDate is not applicable for the arguments (String, Date)

 

Moderator

Re: incremental load tMap help

Hello,

The method TalendDate.parseDate() needs String date not Date date. You can use TalendDate.parseDate("yyyy-MM-dd",TalendDate.formatDate("dd/MM/yyyy")) to achieve your goal.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Six Stars

Re: incremental load tMap help

Thanks for the input but that gets me bellow error;

 

The method formatDate(String, Date) in the type TalendDate is not applicable for the arguments (String)

 

Moderator

Re: incremental load tMap help

Hi,


brawal wrote:

Thanks for the input but that gets me bellow error;

 

The method formatDate(String, Date) in the type TalendDate is not applicable for the arguments (String)

 


Would you mind posting your current expression setting screenshot in tMap into forum?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Six Stars

Re: incremental load tMap help

I have mentioned on the original post. The expression is as;

 

ExpressionTypeVariable
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",row2.updatedtimestamp )Dateformat_date
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",TalendDate.getDate("yyyy-MM-dd HH:mm:ss"))DateCurrent_date
TalendDate.diffDate(Var.Current_date,Var.format_date,"dd") == 126 ?true:falseBooleanOut_Flag

 

And screenshot;

Var.JPG

 

 

Six Stars

Re: incremental load tMap help

Please let me know if you are not clear.

Six Stars

Re: incremental load tMap help


Do This:

- If row2.updatedtimestamp is of type Date then use below expression for format_date
TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",row2.updatedtimestamp) )

- If row2.updatedtimestamp is of type String with value like "23-05-2017" and you want a format like "2017-05-23 12:34:00" then use below expression for format_date
TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",TalendDate.parseDate("dd-MM-yyyy",row2.updatedtimestamp))

- Change the data type of variable format_date to String