Quick SQL question - how to show a number and force 2 decimal places

For example.

If I have a value of 3.6 I want it to display as 3.60.

I am sure it’s simple but I couldn’t find the answer on google.
Basically I’m trying to display money amounts. But when I do convert(money,[stuff to convert]) it displays anything that is a multiple of ten units without the extra zero in the second decimal place. For display purposes I want it to display the zero.

nevermind. I found the answer…

convert(decimal(10,2),[thing I’m converting])

For future reference, you should always store money as an integer number of cents (or pence) and not as a float. It’s much easier to do all your accounting math and divide by 100 only when you need to display a value to the user.

ETA: If your database has a built-in money type, I believe that’s essentially what they do under the hood.

It also avoids problems like some UI declaring that a widget is $14.9999999999999999994 instead of $15.

Hehe I was gonna give that lecture. As a contractor lately I can’t count the number of times I have been tasked to track down a variance only to find that money is being stored as a float or with too much precision and the bits add up to something that was never there.