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  

24 rolling periods



 
 
Thread Tools Display Modes
  #1  
Old November 24th, 2009, 09:08 PM posted to microsoft.public.access.queries
mccloud
external usenet poster
 
Posts: 16
Default 24 rolling periods

We have an ERP system that stores monthly qty's sold information by item. So
Nov 2009 is period 23. Jan 2010 will be period 01. Query will work from a
form where user will enter number of past periods to review and the item.
(.e.g. 6) entering 6 would need to add periods 22 thru 17. I thought about
building a table with (if period = 23 then add these periods together but it
would need to be huge to consider all possible combinations. Any one have a
better way?
  #2  
Old November 24th, 2009, 09:31 PM posted to microsoft.public.access.queries
Duane Hookom
external usenet poster
 
Posts: 7,177
Default 24 rolling periods

What are you actually storing in your table, the period number or a date or
something else? Typically you can use DateAdd() and/or DateSerial() functions
to describe a rolling range of dates. Your criteria might look like:

Between DateSerial(Year(Date()), Month(Date())- 24,1) And Date()

The above would filter to the previous 24 months from the 1st day of the
starting month.


--
Duane Hookom
Microsoft Access MVP


"mccloud" wrote:

We have an ERP system that stores monthly qty's sold information by item. So
Nov 2009 is period 23. Jan 2010 will be period 01. Query will work from a
form where user will enter number of past periods to review and the item.
(.e.g. 6) entering 6 would need to add periods 22 thru 17. I thought about
building a table with (if period = 23 then add these periods together but it
would need to be huge to consider all possible combinations. Any one have a
better way?

  #3  
Old November 25th, 2009, 05:13 PM posted to microsoft.public.access.queries
mccloud
external usenet poster
 
Posts: 16
Default 24 rolling periods

It doesn't store any date information only sales data. So if I look up item
1234 it will have periods 1 thru 24 containing qty sold in each period. So I
need to query the system for the current period (Nov 2009 is 23) and decipher
which periods to include (add together).

"Duane Hookom" wrote:

What are you actually storing in your table, the period number or a date or
something else? Typically you can use DateAdd() and/or DateSerial() functions
to describe a rolling range of dates. Your criteria might look like:

Between DateSerial(Year(Date()), Month(Date())- 24,1) And Date()

The above would filter to the previous 24 months from the 1st day of the
starting month.


--
Duane Hookom
Microsoft Access MVP


"mccloud" wrote:

We have an ERP system that stores monthly qty's sold information by item. So
Nov 2009 is period 23. Jan 2010 will be period 01. Query will work from a
form where user will enter number of past periods to review and the item.
(.e.g. 6) entering 6 would need to add periods 22 thru 17. I thought about
building a table with (if period = 23 then add these periods together but it
would need to be huge to consider all possible combinations. Any one have a
better way?

  #4  
Old November 25th, 2009, 06:59 PM posted to microsoft.public.access.queries
Duane Hookom
external usenet poster
 
Posts: 7,177
Default 24 rolling periods

It sounds like your table is horribly un-normalized where period information
is stored in field names. This would create 24 fields where a normalized
table structure would result in 24 records. If this is your situation, you
can normalize your data with a union query. You haven't provided any field or
table names so I can't provide the SQL of the union query.

--
Duane Hookom
Microsoft Access MVP


"mccloud" wrote:

It doesn't store any date information only sales data. So if I look up item
1234 it will have periods 1 thru 24 containing qty sold in each period. So I
need to query the system for the current period (Nov 2009 is 23) and decipher
which periods to include (add together).

"Duane Hookom" wrote:

What are you actually storing in your table, the period number or a date or
something else? Typically you can use DateAdd() and/or DateSerial() functions
to describe a rolling range of dates. Your criteria might look like:

Between DateSerial(Year(Date()), Month(Date())- 24,1) And Date()

The above would filter to the previous 24 months from the 1st day of the
starting month.


--
Duane Hookom
Microsoft Access MVP


"mccloud" wrote:

We have an ERP system that stores monthly qty's sold information by item. So
Nov 2009 is period 23. Jan 2010 will be period 01. Query will work from a
form where user will enter number of past periods to review and the item.
(.e.g. 6) entering 6 would need to add periods 22 thru 17. I thought about
building a table with (if period = 23 then add these periods together but it
would need to be huge to consider all possible combinations. Any one have a
better way?

 




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 05:14 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.