0

Hi guys;
I need your assistance.
I am extracting some info from my database and I need difference between two fields of money values.
Lets call the fields as Field1,Field2,& Field3.

Field1 = Current Balance
Field2 = Starting Balance
Field3 = Field1 - Field2

From my query, I get Field3 as NULL. I cant understand what is wrong with my formula.

Here is the formula:

Declare @Field1 numeric (18,2),
        @Field2 numeric (18,2),
        @Field3 numeric (18,2)

Select Field1  = @Field1  , Field2 = @Field2
Select @Field3 = @Field1  - @Field2
Select @Field3

Please assist. TQ.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by princekool
0

Look into parameterization with arithmetic operations.

Try this:

Select Field1 = CAST( @Field1 AS MONEY ), Field2 = CAST( @Field2 AS MONEY )
0

Look into parameterization with arithmetic operations.

Try this:

Select Field1 = CAST( @Field1 AS MONEY ), Field2 = CAST( @Field2 AS MONEY )

Thanks Samaru for your contribution.
I tried your hint you gave me but still did not give the results i expected, now field3 is rounding off to a whole figure instead of actual difference.

For example if field1 = 50.35 and field2=20.12, field3 should be 30.23 but its giving 30.

Any ideas why its rounding off??

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.