## extracting decimal part of a number or the integer part?

### extracting decimal part of a number or the integer part?

declare @m money
set @m = 123.67
select @m - cast(@m as int)
select cast(@m as int) - @m

one returns -0.33
and the other returns 0.33

obviously from rounding. How can I extract the decimal or the integer part
without rounding?

Thanks,
Rich

### extracting decimal part of a number or the integer part?

On Thu, 14 Aug 2008 08:12:00 -0700, Rich

I don't see what rounding has to do with what is returned by the
sample code. The sign changes because the terms are reversed in the
subtraction, but the absolute values of the two are identical.

Perhaps you can elaborate?

Roy Harvey
Beacon Falls, CT

### extracting decimal part of a number or the integer part?

>> How can I extract the decimal or the integer part without rounding? <<

1) Stop using MONEY; it has math problems and is proprietary. Use
DECIMAL(s,p) to the proper number of places that your accounting
department needs.

2) One way is to use the FLOOR function
FLOOR (123.67) = 123
likewise:
123.67 - FLOOR (123.67)
123.67 - 123
0.67