FOrmat Float

Hello all, I have a insert statement (below) in which the @pDifference is a float.  If the variable contains 2.7777764646 for example, I want to format so that the insert just puts 2.7 into the database.  Please help!  Urgent!
jwebster77Asked:
Who is Participating?
 
adatheladConnect With a Mentor Commented:
jwebster77 - your solution will put 2.8 into the database though?

If you want the value rounded down to 2.7 instead:
cast(floor(@pDifference * 10) as decimal(5, 1)) / 10
0
 
jwebster77Author Commented:
cast(@pDifference as decimal(5,1))

This is how I did it for anyone interested.
0
 
DireOrbAntCommented:
SELECGT ROUND(@pDifference, 1) AS RoundedValue
0
 
jwebster77Author Commented:
Good point.  I am not sure if we want to round down yet or not...  The example show was more for "decimal places" being limited to 1. I'll give you the credit for the answer though, just in case I need to use the floor function!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.