Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting data type 1

Status
Not open for further replies.

iwm

Programmer
Feb 7, 2001
55
US
I want to get 75.000 but I keep getting 0.75000.

(replace(modifier,right(table.Numberfield,4),'000'))

In an effort to get my desired result I multiplied it by 100.

(replace(modifier,right(table.Numberfield,4),'000'))*100

Multiplying it by 100 generates the following message:

Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '0.75000' to a column of data type int.

It is very important to the client that the number follow the 3 digits, 3 decimal places (e.g. xxx.xxx) format.

Your assistance in this matter is greatly appreciated.
 
What's you starting point?

Prior to muliplting by 100 you have a varchar expression so it cannot be multiplied by 100

I think you need to convert this to decimal first

either

cast(table.Numberfield as decimal(6,3)) * 100

or (and I think this has a few unnecessary steps)

cast((replace(modifier,right(table.Numberfield,4),'000')) as decimal(6,3)) * 100

Damian.
 
That worked! Thank you so much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top