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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

query not showing all data for last month



 
 
Thread Tools Display Modes
  #1  
Old March 1st, 2010, 09:19 PM posted to microsoft.public.access
Shane
external usenet poster
 
Posts: 158
Default query not showing all data for last month

I have written a query with the intent to select data from a table for the
last 12 months only and grouped by individual months.

My group by expression is:

(Year([customerdate])*12+Month([customerdate])-1)

My where expression is:

DateDiff("yyyy",[customerdate],Date())

Criterial is =1.

Until the new year, these expressions worked together fine. Now it will
only pull data from the beginning of the most recent month. February will
all show up in April for example, but not all of March will.

I'm not sure what the fix is. Any help is appreciated.

  #2  
Old March 1st, 2010, 10:18 PM posted to microsoft.public.access
John Spencer
external usenet poster
 
Posts: 7,815
Default query not showing all data for last month

If you want all data between the current date and one year ago then the
criteria would be applied to CustomerDate as follows:

BETWEEN DateAdd("yyyy",-1,Date()) AND Date()

If you want all dated for the prior 12 months. That is it's March 1 2010 and
you want all the data from Feb 1, 2009 to Feb 28, 2010.

BETWEEN DateSerial(Year(Date())-1,Month(Date())-1,1) AND
And DateSerial(Year(Date()),Month(Date()),0)

For March 1, 2009 to March 31, 2010

BETWEEN DateSerial(Year(Date())-1,Month(Date()),1) AND
And DateSerial(Year(Date()),Month(Date())+1,0)

GROUP BY
FORMAT(CustomerDate,"yyyy-mm")


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

shane wrote:
I have written a query with the intent to select data from a table for the
last 12 months only and grouped by individual months.

My group by expression is:

(Year([customerdate])*12+Month([customerdate])-1)

My where expression is:

DateDiff("yyyy",[customerdate],Date())

Criterial is =1.

Until the new year, these expressions worked together fine. Now it will
only pull data from the beginning of the most recent month. February will
all show up in April for example, but not all of March will.

I'm not sure what the fix is. Any help is appreciated.

  #3  
Old March 13th, 2010, 05:56 PM posted to microsoft.public.access
De Jager
external usenet poster
 
Posts: 393
Default query not showing all data for last month


"shane" wrote in message
...
I have written a query with the intent to select data from a table for the
last 12 months only and grouped by individual months.

My group by expression is:

(Year([customerdate])*12+Month([customerdate])-1)

My where expression is:

DateDiff("yyyy",[customerdate],Date())

Criterial is =1.

Until the new year, these expressions worked together fine. Now it will
only pull data from the beginning of the most recent month. February will
all show up in April for example, but not all of March will.

I'm not sure what the fix is. Any help is appreciated.


 




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 08:38 PM.


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