Home All Groups Group Topic Archive Search About

Decimal or Float Type in Percent

Author
17 Dec 2005 9:42 PM
Scott
Below is a sniplet of a select expression that returns a decimal number like
..6153329998

The result is correct, but when I say FormatPercent(objRS("myPercent"),3) in
ASP, I get a type mismatch error.

Both myField1 and myField2 are integer type. I have to CONVERT myField1 into
decimal in order to get a correct return in QA.

Can someone suggest a better data type to convert myField1 so not only will
myPercent render correct in QA, but also allow me to use FormatPercent in
ASP?


CODE:

SUM(CONVERT(DECIMAL(18, 10), myField1)) / SUM(myField2) AS myPercent

Author
18 Dec 2005 3:06 PM
John Bell
Hi

You may want to use your convert function after summing

CONVERT(DECIMAL(18, 10), SUM(myField1))/ SUM(myField2)

You may want to stick with DECIMAL but change your scale and precision.

John

Show quote
"Scott" <sbai***@mileslumber.com> wrote in message
news:O74yeO1AGHA.4080@TK2MSFTNGP14.phx.gbl...
> Below is a sniplet of a select expression that returns a decimal number
> like .6153329998
>
> The result is correct, but when I say FormatPercent(objRS("myPercent"),3)
> in ASP, I get a type mismatch error.
>
> Both myField1 and myField2 are integer type. I have to CONVERT myField1
> into decimal in order to get a correct return in QA.
>
> Can someone suggest a better data type to convert myField1 so not only
> will myPercent render correct in QA, but also allow me to use
> FormatPercent in ASP?
>
>
> CODE:
>
> SUM(CONVERT(DECIMAL(18, 10), myField1)) / SUM(myField2) AS myPercent
>
Author
18 Dec 2005 4:58 PM
Scott
what would the synta be to convert to float?


Show quote
"John Bell" <jbellnewspo***@hotmail.com> wrote in message
news:ebALxS%23AGHA.808@TK2MSFTNGP11.phx.gbl...
> Hi
>
> You may want to use your convert function after summing
>
> CONVERT(DECIMAL(18, 10), SUM(myField1))/ SUM(myField2)
>
> You may want to stick with DECIMAL but change your scale and precision.
>
> John
>
> "Scott" <sbai***@mileslumber.com> wrote in message
> news:O74yeO1AGHA.4080@TK2MSFTNGP14.phx.gbl...
>> Below is a sniplet of a select expression that returns a decimal number
>> like .6153329998
>>
>> The result is correct, but when I say FormatPercent(objRS("myPercent"),3)
>> in ASP, I get a type mismatch error.
>>
>> Both myField1 and myField2 are integer type. I have to CONVERT myField1
>> into decimal in order to get a correct return in QA.
>>
>> Can someone suggest a better data type to convert myField1 so not only
>> will myPercent render correct in QA, but also allow me to use
>> FormatPercent in ASP?
>>
>>
>> CODE:
>>
>> SUM(CONVERT(DECIMAL(18, 10), myField1)) / SUM(myField2) AS myPercent
>>
>
>
Author
18 Dec 2005 6:54 PM
John Bell
Hi

The same but use float as the data type, the syntax for convert is described
in Books online as:

CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

John


Show quote
"Scott" <sbai***@mileslumber.com> wrote in message
news:eEj4bU$AGHA.3840@TK2MSFTNGP15.phx.gbl...
> what would the synta be to convert to float?
>
>
> "John Bell" <jbellnewspo***@hotmail.com> wrote in message
> news:ebALxS%23AGHA.808@TK2MSFTNGP11.phx.gbl...
>> Hi
>>
>> You may want to use your convert function after summing
>>
>> CONVERT(DECIMAL(18, 10), SUM(myField1))/ SUM(myField2)
>>
>> You may want to stick with DECIMAL but change your scale and precision.
>>
>> John
>>
>> "Scott" <sbai***@mileslumber.com> wrote in message
>> news:O74yeO1AGHA.4080@TK2MSFTNGP14.phx.gbl...
>>> Below is a sniplet of a select expression that returns a decimal number
>>> like .6153329998
>>>
>>> The result is correct, but when I say
>>> FormatPercent(objRS("myPercent"),3) in ASP, I get a type mismatch error.
>>>
>>> Both myField1 and myField2 are integer type. I have to CONVERT myField1
>>> into decimal in order to get a correct return in QA.
>>>
>>> Can someone suggest a better data type to convert myField1 so not only
>>> will myPercent render correct in QA, but also allow me to use
>>> FormatPercent in ASP?
>>>
>>>
>>> CODE:
>>>
>>> SUM(CONVERT(DECIMAL(18, 10), myField1)) / SUM(myField2) AS myPercent
>>>
>>
>>
>
>

AddThis Social Bookmark Button