SQLTeam.com | Weblogs | Forums

Currency Format w/ Two Decimals

Hello there. I am sleepy and frustrated with probably a very easy problem.

I am trying to format something as currency w/ 2 decimals. However, what I have keeps rounding.

Format(Case When Cast(ISNULL(SUM(Case When ah.EntryDate Between '12/01/2020' AND '12/22/2020' Then ah.PrincipalAmount Else 0 End),'0') as int) < 0 OR Cast(ISNULL(SUM(Case When ah.EntryDate Between '12/01/2020' AND '12/22/2020' Then ah.PrincipalAmount Else 0 End),'0') as Int) < 0 Then Cast(ISNULL(SUM(Case When ah.EntryDate Between '12/01/2020' AND '12/22/2020' Then ah.PrincipalAmount Else 0 End) - SUM(Case When ah.EntryDate Between '12/01/2019' AND '12/22/2019' Then ah.PrincipalAmount Else 0 End),'0') as int) * -1
** Else Cast(ISNULL(SUM(Case When ah.EntryDate Between '12/01/2020' AND '12/22/2020' Then ah.PrincipalAmount Else 0 End) - SUM(Case When ah.EntryDate Between '12/01/2019' AND '12/22/2019' Then ah.PrincipalAmount Else 0 End),'0') as int)**
** End,'C')**

The first one for example s/b $53,152.97

image

Thank you.

try this... CAST( yourvariable as numeric(10,2))

Thanks for the response. Unfortunately I get the

Error converting data type nvarchar to numeric.

Message

Actually ... that worked. Thank you so much.

Cool.. great..