We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Round Money Field to 2 decimals

on
Medium Priority
712 Views
How do you round a money field to 2 decimals?

I would have thought rount(field, 2) would work but it doesn't

I only want to return:

Original Value = 12.040506  -----   Return Value =  12.04

Thanks
Comment
Watch Question

View Solution Only

CERTIFIED EXPERT
Top Expert 2004

Commented:
What does yours return?  This should be the proper syntax:

round(myfield, 2)

Syntax

ROUND ( numeric_expression, length [ , function ] )

Arguments
numeric_expression
An expression of the exact numeric or approximate numeric data type categories, or types that are implicitly convertible to float.

length
The precision to which numeric_expression is to be rounded. When length is a positive number, numeric_expression is rounded to the number of decimal places specified by length. When length is a negative number, numeric_expression is rounded on the left side of the decimal point, as specified by length.

function
The type of operation to perform. When function is omitted or has a value of 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated.

Commented:
Mine returns the number rounded to that many in the decimal..
For example:

17.701010 = 17.700000

I only want 17.70 returned

Commented:
I think the round is working.  maybe you are assigning the result to a float or other numeric datatype.  You can do this instead of using round.

Declare @RoundValue decimal(18,2)

select @RoundValue = CAST([Original Value] as decimal(18,2))

Not the solution you were looking for? Getting a personalized solution is easy.

Database Consultant
CERTIFIED EXPERT
Top Expert 2009

Commented:
CAST(round(myfield, 2) as Numeric(18,2))
Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile