Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Dollar amount to 2 decimal places

Status
Not open for further replies.
Sep 10, 2009
37
US
I have the below code:

'PTEHeadwayFee' = (SUM(case when y.paycodeid = 259 and y.computeonunits = 1 then (y.billunits*y.billrate)
when y.paycodeid = 259 then ISNULL(y.billrate,0) ELSE 0 end)+
SUM(case when y.paycodeid in (33,286,337,1959) and y.computeonunits = 1 then (y.billunits*y.billrate)
when y.paycodeid in (33,286,337,1959) then ISNULL(y.billrate,0) ELSE 0 end)+
SUM(case when y.paycodeid in(260,264) and y.computeonunits = 1 then (y.billunits*y.billrate)
when y.paycodeid in(260,264) then ISNULL(y.billrate,0) ELSE 0 end)),

it returns: 60.420000000000002

How can I get it to only return 2 decimal places...

Thanks!
 
Convert it to Decimal(20,2)

Code:
'PTEHeadwayFee' = [!]Convert(Decimal(20,2),[/!](SUM(case when y.paycodeid = 259 and y.computeonunits = 1  then (y.billunits*y.billrate)
                when y.paycodeid = 259 then ISNULL(y.billrate,0) ELSE 0 end)+
           SUM(case when y.paycodeid in (33,286,337,1959) and y.computeonunits = 1  then (y.billunits*y.billrate)
                when y.paycodeid in (33,286,337,1959) then ISNULL(y.billrate,0) ELSE 0 end)+
            SUM(case when y.paycodeid in(260,264) and y.computeonunits = 1  then (y.billunits*y.billrate)
                when y.paycodeid in(260,264) then ISNULL(y.billrate,0) ELSE 0 end))[!])[/!],

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top