Converting an int representing number of cents to money
-
05-07-2019 - |
Question
Like this question, except T-SQL instead of php.
206275947 = 2062759.47
etc.
The problem I'm running into is that an attempt to SUM the values in this column is overflowing the integer datatype in SQL.
SUM(CONVERT(money,[PaymentInCentsAmt]))
Is just tacking on ".00" to the end of the value. What obvious thing am I missing?
Solution
how about use money/100?
OTHER TIPS
If you are counting money and especially if youare getting overflows you should try making variables and columns as type decimal that allows as much significance as the calcualations need
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow