Show only this year

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!
 
J

Jerry Whittle

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

John Spencer

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
 
J

John W. Vinson

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top