Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 decimal

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2006-12-28 : 01:04:31
HI fys

Iam doing Earned Leave module..from jan to dec..totdays=150 (an employee worked)
EL days=for 20 days 1 day pay
(ie) totdays/20
150/20 =7.5 eldays to be paid to an employee
while dividing by 20 if the decimal place falls between .1 and .5 should be assigned to .5 and the result should be 7.5

while dividing by 20 if the decimal place falls > .5(for example 7.7,7.8 and so on) should be assigned to 1 and the result should be 8

can any one help???????

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-12-28 : 09:32:21
Check out the ROUND function....

DECLARE @num decimal(10,2)
DECLARE @den decimal(10,2)

SET @num = 150
SET @den = 20

SELECT @num / @den, Round(@num / @den, 0)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-01-01 : 02:57:46
Round will work for decimal values>=0.5
If you want it for >0.5, then tell us why?
Otherwise try
Round(number-0.1,0)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -