DEV Community

loading...

Answer: MySQL Round Up to Nearest 5 Cents

dansimiyu profile image dan-simiyu ・1 min read

Since 100/5 = 20 all we do is multiply by 20, round up to the nearest whole number, and then divide by 20.

(To round up in MySQL use CEIL)

Example for $1.03:

1.03 * 20   = 20.60
CEIL(20.60) = 21.0000
21 / 20     = 1.0500

NOTE: I also round…

Discussion (0)

pic
Editor guide