Even / Odd ID Query?

illdill

Registered User.
Local time
Today, 15:08
Joined
May 9, 2008
Messages
37
Is it possible to sort by weather the ID is even or odd?

I want to display articles in two columns. I am pretty sure I can figure out how to write the date filters, but to get non-matching articles in each column I would need to filter some other way and by ID is the best I can think of...

Thanks
 
In Access,
[ID] mod 2 = 0 returns all even id numbers and
[ID] mod 2 <> 0 returns all odd numbers.

Not sure about FrontPage though.

^
 
Yes, I found this solution for the FP query:

SELECT * FROM articles
WHERE ((([ID] Mod 2)=True))

False for the evens

Thank you
 
Last edited:
What I would like to do now is add an AND clause where one is before the current date and the other after. I am not sure what the current date clause would be. I tried DATE and now() but neither seemed to work.. the articledate feild is designated as text, but the date is entered in short format ie. 6/13/2008


SELECT * FROM articles
WHERE ((([ID] Mod 2)=True)) AND articledate < DATE

SELECT * FROM articles
WHERE ((([ID] Mod 2)=False)) AND articledate > DATE


Thanks
 
Ok, found this too,

SELECT * FROM articles
WHERE ((([ID] Mod 2)=True)) AND articledate < date()

SELECT * FROM articles
WHERE ((([ID] Mod 2)=False)) AND articledate > date()
 
Ok, here is my next task... I want the results to display only a months worth of articles, say half of the month for the odds and half for the evens, here is my unsuccessful attempt:

SELECT * FROM articles WHERE ((([ID] Mod 2)=True)) AND articledate < (date() + 14) AND articledate > date()

Thanks
 
I would have missed articles if that had worked out but here was the correct format:

SELECT * FROM articles WHERE ((([ID] Mod 2)=True)) AND articledate < (date() + 14) AND articledate > (date() - 14)

And for the Evens:

SELECT * FROM articles WHERE ((([ID] Mod 2)=False)) AND articledate < (date() + 14) AND articledate > (date() - 14)
 
Actually the above arguments would result in records for only half the month as the other half would be in the future (silly me) so this is what I have but it still doesn't work properly. I get all results for this month but no results for later days of last month:

SELECT * FROM articles WHERE ((([ID] Mod 2)=True)) AND articledate > (date() - 30)

I should get results for dates such as 5/23/2008 as it lies within 30 days before todays date.

For troubleshootings sake, I also have dates in the future such as a few days ahead and a month ahead. According to the above statement, they 'should' appear as well, but only the ones in the future of this month appear??? For instance 6/18/2008 appears but 7/05/2008 does not.

Thanks...
 
After I realized I was working against two different forms (which is why I wasn't seeing the changes) I was able to get it working. I used now()-30 as a parameter in an Access query along with the Mod2 against the ID.

You can see the results here: http://illdill.org/Atheists/News/results.asp

I've taken out all the test entries but one (repeated 4 times) just to show it as an example before it goes live. It will be embedded in our main sites index page.

Thanks for all your help!
 

Users who are viewing this thread

Back
Top Bottom