Need this year and last year records

  • Thread starter Thread starter Bonnie
  • Start date Start date
B

Bonnie

Hi there! Using A02 on XP. Have a table with records for
multiple years and want my query to pull all [DateRec] for
the current and prior years only. For my criteria in the
grid for field [DateRec]I have:

Year([DateRec])=Year(Now())OR Year([DateRec])=Year(Now()-
1) and I get zero records.

I've tried with a leading = sign, even the current year
part doesn't work by itself.

I'm doing something simple wrong. Can anyone help? Do I
need to create a new field to parse the year first? Not
sure. Thanks in advance for your time!
 
Can you go to SQL view of the query and copy/paste the whole query? Except
for a minor logic error, what you have shown us should return records,
provided there are some with the appropriate values in DateRec. Also, in the
table, what is the data type for DateRec?

The logic error is in
Year([DateRec])=Year(Now()-1)

this will subtract one day from Now() then get the Year. It should be
Year([DateRec])=Year(Now())-1
 
Wayne! Hi there and thank you VERY much! As soon as I
moved the -1 outside the parentheses it works. Must have
messed up something when I tried the front piece alone.
Also, thanks bunches for the fast response!!!-B
-----Original Message-----
Can you go to SQL view of the query and copy/paste the whole query? Except
for a minor logic error, what you have shown us should return records,
provided there are some with the appropriate values in DateRec. Also, in the
table, what is the data type for DateRec?

The logic error is in
Year([DateRec])=Year(Now()-1)

this will subtract one day from Now() then get the Year. It should be
Year([DateRec])=Year(Now())-1

--
Wayne Morgan
MS Access MVP


Hi there! Using A02 on XP. Have a table with records for
multiple years and want my query to pull all [DateRec] for
the current and prior years only. For my criteria in the
grid for field [DateRec]I have:

Year([DateRec])=Year(Now())OR Year([DateRec])=Year(Now ()-
1) and I get zero records.

I've tried with a leading = sign, even the current year
part doesn't work by itself.

I'm doing something simple wrong. Can anyone help? Do I
need to create a new field to parse the year first? Not
sure. Thanks in advance for your time!


.
 
Back
Top