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!

Query Criteria Problem

Status
Not open for further replies.

kopy

Technical User
May 30, 2002
141
0
0
US
I have 2 fields Year and Month. They are both numeric and in YYYY and MM formats.
I’m trying to write a query that will select records that are less than the current date.

For Year I’m using <=Year(Date()).
For Month I’m using <Month(Date()).

Because we are in Feb, I’m only selecting records for Jan.

How would I change the Month criteria to select records like 11 or 12 for months from the previous year?

Thank you in advance for your help,
Kopy
 
kopy said:
select records like 11 or 12 for months from the previous year
[tt]
Select *
From SomeTable
Where fldYear < Year(Date())
And fldMonth Between 11 And 12
[/tt]


---- Andy

There is a great need for a sarcasm font.
 
Add field in a query: (12*[Year]+[Month]) and criteria <(12*Year(Date()+Month(Date())

combo
 
I would try combine the fields.

Are your field names actually Year and Month? These are names of function (reserved words).

SQL:
WHERE YearField * 100 + MonthField < Year(Date()) * 100 + Month(Date())

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top