asked on # Round decimal to nearest .25

Is there a way to round a decimal to nearest .25%?

Example

Select 3.6333 would return 3.75 and

3.6222 would return 3.50

Example

Select 3.6333 would return 3.75 and

3.6222 would return 3.50

Microsoft SQL Server 2005Microsoft SQL ServerMicrosoft Development

multiply by 4, round to nearest whole number, divide by 4.

Log in or sign up to see answer

Become an EE member today7-DAY FREE TRIAL

Members can start a 7-Day Free trial then enjoy unlimited access to the platform

or

Learn why we charge membership fees

We get it - no one likes a content blocker. Take one extra minute and find out why we block content.

Not exactly the question you had in mind?

Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.

ask a question
Or, one other alternative:

floor((value + 0.12) / 0.25) * 0.25

select value, floor((value + 0.12) / 0.25) * 0.25 as rounded_value

from (

select 3.6333 as value union all --would return 3.75

select 3.6222 --would return 3.50

) as data

floor((value + 0.12) / 0.25) * 0.25

select value, floor((value + 0.12) / 0.25) * 0.25 as rounded_value

from (

select 3.6333 as value union all --would return 3.75

select 3.6222 --would return 3.50

) as data

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat

William Peck

Scott - I think you may be slightly off. 3.63 would be the point where your number begins to round up to 3.75, but it should start rounding up at 3.625.

The alternative would be floor((value + 0.125) / 0.25) * 0.25

I am using the floor function in another program to test, but I do think it should be 0.125, not 0.12.

The alternative would be floor((value + 0.125) / 0.25) * 0.25

I am using the floor function in another program to test, but I do think it should be 0.125, not 0.12.

OK, 0.125 makes sense.

I was trying to find a method where you could round at any value, such as .15, rather than using something like "* 4", where it requires having an even multiple and re-calculating the multiplier.

I was trying to find a method where you could round at any value, such as .15, rather than using something like "* 4", where it requires having an even multiple and re-calculating the multiplier.

Cleanest answer for me

Get an unlimited membership to EE for less than $4 a week.

Unlimited question asking, solutions, articles and more.