A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Show only this year



 
 
Thread Tools Display Modes
  #1  
Old May 12th, 2010, 07:42 PM posted to microsoft.public.access.queries
ZBB
external usenet poster
 
Posts: 1
Default Show only this year

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!
  #2  
Old May 12th, 2010, 08:22 PM posted to microsoft.public.access.queries
raskew via AccessMonster.com
external usenet poster
 
Posts: 370
Default Show only this year

Hi -

You need to rename your date field since Date is a reserved word in Access.
Your Where statement would look like:

WHERE (((Year([MyDte]))=Year(Now())) AND ((Month([MypDte]))=Month(Now())));

HTH - Bob
ZBB wrote:
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!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201005/1

  #3  
Old May 12th, 2010, 08:33 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Show only this year

SELECT DISTINCTROW [FC Customers].*
FROM [FC Customers]
WHERE Month([Date])=Month(Now())
AND Year([Date])=Year(Now());
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

"ZBB" wrote:

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!

  #4  
Old May 12th, 2010, 09:01 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Show only this year

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

ZBB wrote:
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!

  #5  
Old May 12th, 2010, 09:21 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Show only this year

On Wed, 12 May 2010 11:42:01 -0700, ZBB wrote:

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)

--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:16 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.