SQL datatype for money??

Soldato
Joined
18 Oct 2002
Posts
9,044
Location
London
I started off using varchar because I could input:

29,000

But then I wanted to use this field for calculations too:

Code:
SELECT Salary, ROUND((Salary / 12),2) AS MonthlySalary

This caused an error, obviously. So I changed to decimal type (although the same seems to happen for double and int)
So now my output is like this:

29000
2416.67


Unfortunately I've lost the lovely , which separates the thousands from the hundreds....
Is there anyway to get the best of both worlds? :confused:
 
Yeah sorry I'm using mySQL. Don't you hate it when people don't tell you what they're using.....

I guess I should just create some conversion function. Although I'm not entirely fond on having to convert to pennies, maybe that's the correct way, but this isn't a 'live' app :)

Thanks guys!
 
Back
Top Bottom