| re: How to test a bit in an integer?
Thank you Justin, thank you Arno
- I need a solution at SQL level as in fact I am not in Access
- I have taken the sample of bit 2**0 but in fact I need any bit.
Mmm, in fact I think that this problem has no solution...
Pierre
Justin Hoffman a écrit :[color=blue]
> "Pierre Couderc" <pierre@couderc.ccNOSPAM> wrote in message
> news:d2rn0c$1dqg$2@biggoron.nerim.net...
>[color=green]
>>I want to test a bit in an integer and I have the SQL command :
>>SELECT myfiels,int FROM table WHERE (( int & 1)=1);
>>I want to get all the lines where int is even.
>>This instruction does not work in JET motor. I suppose that my syntax is
>>false somewhere.
>>
>>What am I missing?
>>
>>Thank you in advance.
>>Pierre Couderc[/color]
>
>
>
> In general, if you want to test a bit, you would need to create your own
> function in a module, e.g.
>
> Public Function BitwiseAnd(lngOne As Long, lngTwo As Long) As Long
> BitwiseAnd = lngOne And lngTwo
> End Function
>
> Then you can use this fnction in your query.
>
> However, in your specific example, why not use the MOD operator such as
> NewField: [MyField] MOD 2
> which returns zero for even rows and one for odd rows.
>
>[/color] |