October 7, 2005 at 10:16 am
I have this:
if (@currentBid - @NewBid) <> cast(@bidincrement as money)
u can prolly figure it's for an auction. Well the way it works, if bid is 200, u can go up to 250 if @bidincrement is 50. But it won't let us go directly to 150 or 100...
so how can i check for proper increments?
pretty much i need to check if (@currentBid - @NewBid) / @bidincrement is a whole number
how can i do that?
October 7, 2005 at 10:20 am
Use Modulo % it shows the remainder value in a division equation.
Select 10 % 5
Result
0
Select 10 % 4
Result
2
if ((@currentBid - @NewBid) % @bidincrement) = 0
October 7, 2005 at 10:27 am
Thank you... I forgot about modulo existence
October 7, 2005 at 10:39 am
oh, how would I do that if originally @currentBid and @NewBid are data type 'money' and @bidincrement is 'varchar'
October 7, 2005 at 1:55 pm
Just cast them explicitly to int. like:
if (Cast (@currentBid - @NewBid as int) % Cast(@bidincrement as int)) = 0
* Noel
October 10, 2005 at 6:49 am
won't work... i get an error... like data type int and convert type modulo...
ok... let's try w/o modulo
how can I do some sort of a INSTRING to cut numbers before '.'
like let's say result is 125.0000 - how do i get those 0000?
Pretty much I want a check on last 4 digits for example of result from division
October 10, 2005 at 4:58 pm
Well, something like:
myMoney = 125.0000
set myCheck = select(myMoney - round(myMoney,0))
if myCheck != 0
begin
'something
end
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply