Jul 17, 2006 #1 katgirl Programmer Jul 6, 2006 114 US Just wondering the best way to round a number as part of select statement. Right now I am getting numbers like 1.05838784 - I would like to round this to 1.06. Is there a function to do this... or a datatype I can cast to. Thanks
Just wondering the best way to round a number as part of select statement. Right now I am getting numbers like 1.05838784 - I would like to round this to 1.06. Is there a function to do this... or a datatype I can cast to. Thanks
Jul 17, 2006 #2 Walid Programmer May 18, 2000 382 US There is a function and it is called – surprise – ROUND() SELECT ROUND(1.05838784,2) will give you what you want Walid Magd (MCP) The primary challenge of every software development team is to engineer the illusion of simplicity in the face of essential complexity. -Grady Booch Upvote 0 Downvote
There is a function and it is called – surprise – ROUND() SELECT ROUND(1.05838784,2) will give you what you want Walid Magd (MCP) The primary challenge of every software development team is to engineer the illusion of simplicity in the face of essential complexity. -Grady Booch
Jul 17, 2006 Thread starter #3 katgirl Programmer Jul 6, 2006 114 US I tried that... I get back 1.060000000 ! Don't want to see all those extra zeroes Upvote 0 Downvote
Jul 17, 2006 #4 Walid Programmer May 18, 2000 382 US SELECT STR(ROUND(1.05838784,2),10,2) Adjust 10 or calculate it using the length of the integral part. Read the help for more info. Good luck Walid Magd (MCP) The primary challenge of every software development team is to engineer the illusion of simplicity in the face of essential complexity. -Grady Booch Upvote 0 Downvote
SELECT STR(ROUND(1.05838784,2),10,2) Adjust 10 or calculate it using the length of the integral part. Read the help for more info. Good luck Walid Magd (MCP) The primary challenge of every software development team is to engineer the illusion of simplicity in the face of essential complexity. -Grady Booch
Jul 18, 2006 #5 gmmastros Programmer Feb 15, 2005 14,901 US You could also convert to decimal: Select Convert(Decimal(18,2), 1.05838784) -George Strong and bitter words indicate a weak cause. - Fortune cookie wisdom Upvote 0 Downvote
You could also convert to decimal: Select Convert(Decimal(18,2), 1.05838784) -George Strong and bitter words indicate a weak cause. - Fortune cookie wisdom