Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

querying based on odd/even numbers

Status
Not open for further replies.

czarjosh

Technical User
Jul 14, 2002
79
0
0
US
i Have a field that has numbers in (though they stored as text) I want to be able to pull just even or odd numbers? Can I do this?
 
Hi,

Even
Code:
Select * From MyTable Where MOD([MyField],2)=0
Odd
Code:
Select * From MyTable Where MOD([MyField],2)=1


Skip,
[sub]
[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue][/sub]
 
will that even work, though the numbers are stored at text?
 
Take a look at the Val function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I am not familiar with the VAL function. Can somehelp me out with it?

 
From Skip's code:
Select * From MyTable Where MOD(Val([MyField]),2)=1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
JonFer,

You are correct. I assumed that the function would be similar to Excel, but it's the VB syntax, ([Field] Mod 2)=1!

Skip,
[sub]
[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top