Bitwise AND in Access query

A

Allen Browne

In Access 2000 and later, you can use the BAND operator (Binary AND), but
only if you run the query under ADO code.

The Access interface uses DAO (the native Access language), so you can't run
the query there.
 
C

Chaim

I believe the AND operator will do a bitwise and:

255 and 64 ---> 64

1 AND 2 ---> 0

1 AND 3 ----> 1
 
M

Michel Walsh

Hi,


Not in SQL.
====================================

? CurrentProject.Connection.Execute( "SELECT 255 AND 64").FIelds(0).Value
-1


? CurrentProject.Connection.Execute( "SELECT 255 BAND 64").FIelds(0).Value
64

=====================================


Hoping it may help,
Vanderghast, Access MVP
 
J

John Spencer (MVP)

But you can write a simple user-defined function to do the bitwise and for you
and call that from the query.
 
S

Sophie Guo [MSFT]

Hello,

You may create a Access project, then run the following code:

? CurrentProject.Connection.Execute( "SELECT 255 & 64").FIelds(0).Value

It will return 64. I test it on my side and it works fine. I hope it's
helpful.

Sophie Guo
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security

=====================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Top