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
  • Last Modified:

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
Asked:
NerishaB
3 Solutions
 
Pratima PharandeCommented:
TotalHours_Dec = Cast (datediff(minute, Min(ClockIn), MAX(ClockOut)) / 60.0 as decimal(4,2))
0
 
lisa_mcCommented:
could try

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

see if that helps
0
 
mayank_joshiCommented:
you may use this:-

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

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Imran Javed ZiaConsultant 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
 
NerishaBAuthor Commented:
Thanks guys all works well
0
 
Alpesh PatelAssistant ConsultantCommented:
TotalHours_Dec = Round(datediff(minute, Min(ClockIn), MAX(ClockOut)) / 60.0,2)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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