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

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

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

>> 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

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

Sorry about my ambiguity.

if a number is 123.45 -- cast(123.45 as int) will return 123

if a number is 123.75 -- cast(123.75 as int) will return 124

The FLOOR function will extract the int portion of the number.

Thank you all for your replies and help.

if a number is 123.45 -- cast(123.45 as int) will return 123

if a number is 123.75 -- cast(123.75 as int) will return 124

The FLOOR function will extract the int portion of the number.

Thank you all for your replies and help.

1. Need to remove the integer part and keep the fractional part of a double or decimal

2. Assembly part number vs. Detail part number

3. Replace Old Part Numbers with New Part Numbers in a Macro.

4. Searching for items by vendor part number or manufacturer part number

5. Displaying integer part of a decimal value

6. How to display integer value when there is no decimal part?

7. Representing decimal part as regular integer on low 16 bits?

9. extract Integer part of TimeSpan.TotalMinutes?

10. Parts made up of parts made up of parts

12. Semaphore events and working part-part-part time.

13. Web Part page and Web Part Zone and Web Part life-cycle.

14. Conditional formatting & decimal part of a number in cell

15. Part specification... is neither an integer nor a list of integers

4 post • Page:**1** of **1**