From: nadesico on
I have three fields in a table, and want to determine the total of the
occurrences by a certain time period. The data I have looks like this.

FGC RDate Occurrences
81 2009/01 1
81 2009/02 1
81 2009/03 1
81 2009/04 1
81 2009/05 5
81 2009/06 84
81 2009/07 1
81 2009/08 6
81 2009/09 3
81 2009/10 1
81 2009/11 5

And I want it to look like this

FGC 81

Less Than 3 Months 9
3 Or More Months 91
6 Or More Months 7
9 Or More Months 2
12 Or More Months 0

The month that the results are based off of is 2009/11. For this example, I
am using a specific month, but for future use the month will be determined by
Date() converted to yyyy/mm.
Any help would be greatly appreciated.

Thanks

From: PieterLinden via AccessMonster.com on
First off, you have to use DateDiff() to determine the number of time units
between the two dates.

e.g.
DateDiff("q", FirstDate, SecondDate) will return the number of quarters
between FirstDate and SecondDate. Then you can use switch to

nadesico wrote:
>I have three fields in a table, and want to determine the total of the
>occurrences by a certain time period. The data I have looks like this.
>
>FGC RDate Occurrences
>81 2009/01 1
>81 2009/02 1
>81 2009/03 1
>81 2009/04 1
>81 2009/05 5
>81 2009/06 84
>81 2009/07 1
>81 2009/08 6
>81 2009/09 3
>81 2009/10 1
>81 2009/11 5
>
>And I want it to look like this
>
>FGC 81
>
>Less Than 3 Months 9
>3 Or More Months 91
>6 Or More Months 7
>9 Or More Months 2
>12 Or More Months 0
>
>The month that the results are based off of is 2009/11. For this example, I
>am using a specific month, but for future use the month will be determined by
>Date() converted to yyyy/mm.
>Any help would be greatly appreciated.
>
>Thanks

Do something like this:
SELECT tblDates.SomeDate, DateDiff("q",[SomeDate],Date()) AS QuartersAgo,
Switch([QuartersAgo]=0,"Less than 3 Months",[QuartersAgo]=1,"3 or More
Months",[QuartersAgo]=2,"6 Or More Months",[QuartersAgo]=3,"9 Or More Months",
[QuartersAgo]=4,"12 Or More Months",[QuartersAgo]=5,"15 Or More Months") AS
QuartersText
FROM tblDates;


Then create a query that groups by the QuartersText and does a count.

--
Message posted via http://www.accessmonster.com