|
Question : how to round $elling price to nearest fifty cents
|
|
I want to round a dollar amount to nearest fifty cents up to $500 ; round to nearest dollar from 501 to $1000 and round to nearest $5.00 over $1000 I would like to be ablle to go this to a field selling price, globaly over all records, or as a result of a function run at after update of a single record, or when the field selling price is being calculated I would be so gratefull for this proceedure Su
|
|
Answer : how to round $elling price to nearest fifty cents
|
|
Whoops I got a bit of it wrong for the rounding to 50 cents. Now that I think about it, there's a MUCH simpler formula. Simply multiply the price by two, round, then divide by two. Piece of cake.
roundedprice = round(price * 2) / 2
Similarely to round to the nearest 5 dollars, simply divide by 5, so divide by 5. Then round to the nearest dollar, and then multiply by 5.
roundedprice = round(price / 5) * 5
Sheesh why didn't I just say that before? Scratch my entire post above.
|
|
|
|