[resolved] Convert the BigDecimal Value into Date format

One Star

[resolved] Convert the BigDecimal Value into Date format

Hi,
I am using Talend Data Integration Tool (5.3.1r104014), i would like to integrate the data from Source database to destination data base with using tmap_1 component, the source and destination are MSSQL.
So From the source data base they define the date format like this 20101109(i.e. data type is Bigdecimal), but in the destination the date format is dd/mm/yyyy (i.e. data type is date).
I am unable to convert the Bigdecimal value into Date format and unable to give the null value.
Code:
TalendDate.parseDate("yyyy-MM-dd",TalendDate.formatDate("yyyy-MM-dd",TalendDate.parseDate("yyyyMMdd",row1.newColumn.toString())))
When i am execute the above mentioned code in the Expression Builder, the result is "Exception in component tRowGenerator_1" appear.
And also i am unable to give the null date format like "12/31/1599" , Please find the attached screen shot.
Please help on the above two issues
Thanks in advance
Siva

Accepted Solutions
Community Manager

Re: [resolved] Convert the BigDecimal Value into Date format

Hi
According to your request, you need to convert null to a fixed date, before inserting it to target database, for example:
row1.newColumn==null?TalendDate.parseDate("MM/dd/yyyy", "12/31/1599"):TalendDate.parseDate("yyyyMMdd",row1.newColumn.toString())
And set the data type of this column as Date in the output table of tMap.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Moderator

Re: [resolved] Convert the BigDecimal Value into Date format

Hi,
When i am execute the above mentioned code in the Expression Builder, the result is "Exception in component tRowGenerator_1" appear.

The Test! button can't understand row2.AUDIT if the expression refers to a column value, you need to execute the job to see if the job works without any compilation error or Java error, we usually use the Test! button to test a function, as the screenshot showed.
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.
One Star

Re: [resolved] Convert the BigDecimal Value into Date format

Hi Sabrina,
Thank you for the information,
I would like to pass the null date like "12/31/1599", Is there any possibility to pass the null date,
Please let me know, what is the function to pass the null date value.
Thanks in Advance
Siva
Moderator

Re: [resolved] Convert the BigDecimal Value into Date format

Hi,
Do you mean convert the null string or empty into 12/31/1599 by default?
Such as:
Input source:
12/04/2011;
null;
;
08/23/2012;
Expected result:
12/04/2011;
12/31/1599;
12/31/1599;
08/23/2012; ?
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.
One Star

Re: [resolved] Convert the BigDecimal Value into Date format

Hi,
When i give the input as 12/04/2011; i have faced the first screen error data type mismatch.
if i give the input null; the second screen shot error appear.
So what i am expected, i want a null date to pass the destination columns like 12/31/1599.
Please help us
Thanks
Siva
Community Manager

Re: [resolved] Convert the BigDecimal Value into Date format

Hi
According to your request, you need to convert null to a fixed date, before inserting it to target database, for example:
row1.newColumn==null?TalendDate.parseDate("MM/dd/yyyy", "12/31/1599"):TalendDate.parseDate("yyyyMMdd",row1.newColumn.toString())
And set the data type of this column as Date in the output table of tMap.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Convert the BigDecimal Value into Date format

Hello i'm when i'm convert unix date to readable date i got the default value for the timestamps date any help Smiley Happy?
Community Manager

Re: [resolved] Convert the BigDecimal Value into Date format

Hello i'm when i'm convert unix date to readable date i got the default value for the timestamps date any help Smiley Happy?

Take a look at a related topic:
http://www.talendforge.org/forum/viewtopic.php?id=6160
If you still have problem, please describe your problem with more details.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Convert the BigDecimal Value into Date format

How to convert null into new BigDecimal?
Community Manager

Re: [resolved] Convert the BigDecimal Value into Date format

How to convert null into new BigDecimal?

Can you please explain your requirement with more details? Are you getting error when convert a column data to BigDecimal type?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Convert the BigDecimal Value into Date format

This is now okay.
thank you