Solved

FOrmat Float

Posted on 2006-10-25
4
528 Views
Last Modified: 2011-04-14
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
Comment
Question by:jwebster77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:jwebster77
ID: 17804763
cast(@pDifference as decimal(5,1))

This is how I did it for anyone interested.
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 17804767
SELECGT ROUND(@pDifference, 1) AS RoundedValue
0
 
LVL 23

Accepted Solution

by:
adathelad earned 500 total points
ID: 17804918
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
 

Author Comment

by:jwebster77
ID: 17805164
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

736 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question