I need to round money values up to the nearest cent, then do some operations on that rounded value. I cannot use Round() because this will also round down. These are all money values.
123.4567 --> 123.46
1.1349 --> 1.14
Is there any way to do this in SQL? If I need a UDF, please provide suggestion on how to accomplish code for that UDF.
EDIT: Data is stored as Float.
Rounding to the nearest dollar Round down for a dollar amount that has 0 to 49 cents. For example, $89.27 rounds down to $89. Round up for dollar amounts that have 50 to 99 cents. For example, $53.52 rounds up to $54.
The US and Canadian dollar can't be transacted with more than 2 decimal places. When numbers represent money, we use rounding to replace an un-representable, un-transactable money amount with one that represents a cash tender.
0.5 rounded off to the nearest whole number is 1. Since, the value after decimal is equal to 5, then the number is rounded up to the next whole number. Hence, the whole number of 0.5 will be 1.
CEILING(moneyvalue * 100) / 100
perhaps? Convert to pennies, round up to nearest whole penny, then convert back to dollars.
Use Ceiling
select ceiling(1.1349 * 100) / 100
result is 1.14
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With