Link to home
Start Free TrialLog in
Avatar of NerishaB
NerishaBFlag for South Africa

asked on

SQL Rounding to 2 decimal places

Hi,

How do I round of a decimal number to 2 decimal places?

My query contains:

TotalHours_Dec = datediff(minute, Min(ClockIn), MAX(ClockOut)) / 60.0

Which gives me a result of 11.36667

I would like it to display 11.37
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

Try following:
Set @TotalHours_Dec = convert(decimal(12,2), datediff(minute, Min(ClockIn), MAX(ClockOut)) / 60.0)

TotalHours_Dec = convert(decimal(12,2), datediff(minute, Min(ClockIn), MAX(ClockOut)) / 60.0)


Thanks
Avatar of NerishaB

ASKER

Thanks guys all works well
TotalHours_Dec = Round(datediff(minute, Min(ClockIn), MAX(ClockOut)) / 60.0,2)