Solved

converting integer field into money

Posted on 2008-10-06
5
323 Views
Last Modified: 2012-05-05
I'm converting a data file that has a fee field with no decimals. I need to cast this field as money but I'm stuck on how to proceed with this.

Ex:

data field = 25557
want to to convert it to show 255.57
0
Comment
Question by:jorbroni
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22654416
select cast(datafield as numeric(10,2)/100
from YourTable
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22654420
or perhaps this, depending upon your db engine:


select convert(numeric(10,2), yourDataField)/100
from YourTable
0
 
LVL 1

Author Comment

by:jorbroni
ID: 22654464

I get the following error

Arithmetic overflow error converting varchar to data type numeric.
0
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 250 total points
ID: 22654484
Well 10,2 was just a starting point.  If you have greater than 8 digits to the left (>99 million) then you need to expand your data type beyond 10,2.
0
 
LVL 1

Author Comment

by:jorbroni
ID: 22654491

Nevermind,

I figured out what I did wrong with your script.

Thanks for your help sir.
0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question