Results 1 to 2 of 2

Thread: How was the Following Value calculated

  1. #1

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    How was the Following Value calculated

    Good Day

    i have a RadMaskedTextBox which gets binded with the following value from the DB
    Code:
      <telerik:RadMaskedTextBox IsEnabled="False" Height="22" HorizontalAlignment="Right"    Mask="p1" MaskType="Numeric" MaskedText="0" EmptyContent="0" Margin="0,281,880,0" Name="RETURNONASSETS" telerik:StyleManager.Theme="Metro" VerticalAlignment="Top" Width="227" TabIndex="8" SelectionOnFocus="SelectAll" Grid.Column="1" />

    <b>0.0473445085040537 </b>

    and on the application it format the value as


    Code:
    4.7 %


    which is Correct , now i want to understand how did it come to 4.7 , i tried this


    Code:
        select round(0.0473445085040537,2)
    
    	    select  round(0.0473445085040537,3)
    but my calc here does not give me 4.7 , i need help with this TSQL to make it 4.7

  2. #2
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: How was the Following Value calculated

    Hi,

    You need to check that the rounding logic in SQL is the same as the rounding logic in the telerik:RadMaskedTextBox control and if so you can do it like this:-

    Code:
    SELECT CAST(CAST(0.0473445085040537 * 100 AS decimal(4, 1)) AS nvarchar(5)) + N'%' AS myPercentage
    Hope that helps.

    Cheers,

    Ian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width