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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call up years as ODD or EVEN

Status
Not open for further replies.

1JohnnyV

Technical User
Jun 6, 2003
11
US
I have a Query that I would like to call up the year as either ODD or EVEN without having to put the specific year in the Query e.g.(1992; 1994; 1996; or 1997; 1999; 2001 etc.). Could this be done at runtime?
 
Hi,

It is certainly possible to determine whether a year (or any other number) is odd or even within a query, but in order to do this, you need to know what the year is.

Setting up a custom query field such as this will do:

Expr1: Iif(Year(Datefield) Mod 2 = 0, "Even", "Odd")

What this does is takes the remainder of dividing it by 2; if it is 0 it prints "Even" otherwise it prints "Odd".

You will need to change "Datefield" to the name of the date field within your table.

John
 
Thanks jrbarnett, that worked like a charm after substituting the field name..........
 
Thanks jrbarnett, that worked like a charm after substituting the field name..........

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top