Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1184

# 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
0
NerishaB
3 Solutions

Commented:
TotalHours_Dec = Cast (datediff(minute, Min(ClockIn), MAX(ClockOut)) / 60.0 as decimal(4,2))
0

Commented:
could try

CONVERT(decimal(18, 2), ROUND(TotalHours_Dec, 2))

see if that helps
0

Commented:
you may use this:-

``````select cast(Round(11.36667,2) as numeric(18,2))
``````
0

Consultant Software Engineer - .NET ArchitectCommented:
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
0

Author Commented:
Thanks guys all works well
0

Assistant ConsultantCommented:
TotalHours_Dec = Round(datediff(minute, Min(ClockIn), MAX(ClockOut)) / 60.0,2)
0

## Featured Post

Tackle projects and never again get stuck behind a technical roadblock.