Solved

converting integer field into money

Posted on 2008-10-06
5
318 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mySql Syntax 7 44
return result by latest date - oracle query 21 69
SQL query 4 47
Convert char to decimal in a SQL Server View 14 45
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now