Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    20

    Question Unanswered: calculation problem

    In the following calculation I am receiving my output as 000000.9000. I need it to look like 00000000.90. I cant seem to loose the 2 zeros at the end. Can anyone help me with this? Keep in mind that my output has to be varchar.

    right('00000000000' + cast((st.rate_dlr * .01) * 10 as varchar),11)

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    If you only need positive values, you can use:
    PHP Code:
    SELECT Replace(Str(st.rate_dlr 0.01112), ' ''0'
    Allowing negative numbers gets a bit more complicated, but until you decide how you want them formatted I could only guess anyway.

    -PatP

  3. #3
    Join Date
    Feb 2004
    Posts
    20
    Thanks for your reply...I finally figured it out. Here is basically what I did...........

    select Cost_cast = right('000000.00' + convert(varchar,convert(decimal(6,2),round(4444.22 22,2))),9)

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Before you get too frisky, I'd check
    PHP Code:
    select Cost_cast right('000000.00'
    +  convert(varchar,convert(decimal(6,2)
    ,  
    round(44.2222,2))),9
    I think you might prefer my solution!

    -PatP

Posting Permissions

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