Show only this year

  • Thread starter Thread starter ZBB
  • Start date Start date
Z

ZBB

I'm stuck. I can't change the following statement correctly to show only the
current year in addition to the current month. It pulls the prior years!

SELECT DISTINCTROW [FC Customers].* FROM [FC Customers] WHERE
(((Month([Date]))=Month(Now())));

Help!
 
SELECT DISTINCTROW [FC Customers].*
FROM [FC Customers]
WHERE Month([Date])=Month(Now())
AND Year([Date])=Year(Now());
 
SELECT DISTINCTROW [FC Customers].* FROM [FC Customers]
WHERE [Date] >= DateSerial(Year(Now()),Month(Now()),1) AND
[Date] < DateSerial(Year(Now()),Month(Now())+1 ,1)

That will be the most efficient way to do this. Especially if you have a
large volume of records.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
I'm stuck. I can't change the following statement correctly to show only the
current year in addition to the current month. It pulls the prior years!

SELECT DISTINCTROW [FC Customers].* FROM [FC Customers] WHERE
(((Month([Date]))=Month(Now())));

Help!

Rather than a (very inefficient) search comparing one calculated field to
another calculated field, I'd suggest searching the (misnamed, it's a reserved
word!!!) [Date] field directly:

SELECT DISTINCTROW [FC Customers].* FROM [FC Customers] WHERE [Date] >=
DateSerial(Year(Date()), Month(Date()), 1) AND [Date] <
DateSerial(Year(Date()), Month(Date()) + 1, 1)
 
Back
Top