question

SanketJJ avatar image
SanketJJ asked

How to convert a decimal to the nearest quarter?

How do I convert a decimal to the nearest 1/4th? For ex: 0.3 ------ 0.25 10.85 ---- 10.75 85.9 ----- 86.00
decimalround
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Magnus Ahlkvist avatar image
Magnus Ahlkvist answered
You could multiply the value by four, then round it to zero decimals, divide that value by four and finally cast it to two decimals. Like this: DECLARE @n decimal(10,4) = '20.7531'; SELECT CAST( ROUND(@n * 4,0) / 4 AS decimal(8,2));
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.