• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 532
  • Last Modified:

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!
0
jwebster77
Asked:
jwebster77
  • 2
1 Solution
 
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
 
adatheladCommented:
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:
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now