Converting numbers to a character type  Converting date and time information

Chapter 15: Using the Built-In Functions in Queries

Rounding during conversion to or from money types

The money and smallmoney types store four digits to the right of the decimal point, but round up to the nearest hundredth (.01) for display purposes. When data is converted to a money type, it is rounded up to four decimal places.

Data converted from a money type follows the same rounding behavior if possible. If the new type is an exact numeric with less than 3 decimal places, the data is rounded to the scale of the new type. For example, when $4.50 is converted to an integer, it yields 5:

select convert(int, $4.50)
----------- 
          5
 
(1 row affected)

Adaptive Server assumes that data converted to money or smallmoney is in full currency units, such as dollars, rather than in fractional units, such as cents. For example, the integer value of five is converted to the money equivalent of five dollars, not five cents, in us_english.





Copyright © 2005. Sybase Inc. All rights reserved. Converting date and time information

View this book as PDF