Page 1 of 1

Float to Numeric conversion

Posted: Thu Nov 04, 2010 8:12 am
by Harini
Hello .. :)

Sorry to post a data type conversion questionn again.. I am facing quite a lot of data type conversion offlate. .

Here it is..

The source has the following data,

3.1120 (Float of length 10). How do i convert it to Numeric datatype of length 15?


Thanks a ton !

Posted: Thu Nov 04, 2010 8:18 am
by anbu
Check DecimalToDecimal()

Posted: Mon Nov 08, 2010 4:48 am
by Harini
anbu wrote:Check DecimalToDecimal()
I tried DFLOAT to Decimal conversion.. It is loading the data, but it is loading it as 10 digits after decimal, where in the input data contains only 4 digits after the decimal point.. The target column is numeric.. and the scale is 10..Is that why it is loading 10 digits??? but i am trying to populate the data whatever is coming in the input column...

any thoughts on this?

Posted: Mon Nov 08, 2010 6:34 am
by nitkuar
The target column is numeric.. and the scale is 10..Is that why it is loading 10 digits???
what is scale and precision of this field specified in target column?

Posted: Tue Nov 09, 2010 12:54 am
by Harini
Length : 15 ; Scale 10

Thanks

Posted: Tue Nov 09, 2010 11:38 pm
by Harini
Harini wrote:Length : 15 ; Scale 10

Thanks
Now i have changed the source field as 'Numeric' datatype,Length to 10, Scale to 15

The target has the same datatypes and length, and scale..

When i load this i get the 3.1120000000 ( 6 zeros appended in the end) . I used Trim(columnname, "0" , "T" ) And the result is unaltered after using this function too.. Any suggesstions pls??

Thanks

Posted: Wed Nov 10, 2010 12:32 am
by ray.wurlod
The decimal number is not stored with the trailing zeroes, it is only displayed with them. You can not get rid of them in the View Data dialog. If you want to get rid of them into a text file, declare the data type as VarChar, then Trim() will work.

Posted: Wed Nov 10, 2010 1:08 am
by Harini
ray.wurlod wrote:The decimal number is not stored with the trailing zeroes, it is only displayed with them. You can not get rid of them in the View Data dialog. If you want to get rid of them into a text file, declar ...
Sorry, am not a premium member yet. Still, the data is getting loaded with the zeros in the database. My target is SQL Server. By default the source column is read as 'float' .. I changed it to 'numeric' since the target column is also numeric..

Thanks

Posted: Wed Nov 10, 2010 7:34 am
by chulett
Harini wrote:Still, the data is getting loaded with the zeros in the database.
No, it's not. :?

As noted, that is an external representation of the internal value and the viewer is "adding" the zeroes. Trimming the zeroes is a waste of time.

Posted: Thu Dec 09, 2010 8:45 am
by Harini
chulett wrote:
Harini wrote:Still, the data is getting loaded with the zeros in the database.
No, it's not. :?

As noted, that is an external representation of the internal value and the viewer is "adding" the zeroes. Trimming the zeroes is a waste of time.
Thanks everybody !