web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Tajwal's Blog / Round Up or Down to custom ...

Round Up or Down to custom number in SQL Server

Community Member Profile Picture Community Member

Recently I faced the scenario where end user wanted, to check the first decimal number of Net Salary, if it’s greater then or equal to 4 (0.4) round up, otherwise, round down it.

I was able to solve it using below piece of code.

Declare @NetAmount numeric(18,5), @PaymentAmount numeric(18,5);

set @PaymentAmount = FLOOR(@NetAmount)+CASE WHEN Round(@NetAmount, 1, 1) % 1 >= 0.4 THEN 1 ELSE 0 END ;


This was originally posted here.

Comments

*This post is locked for comments