Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Rolling months display

New Here ,
May 28, 2008 May 28, 2008
In my form, I have multiple pulldowns for the user to select. Two are required and they are the month and the year. The others are optional. When they submit, here is the query I use in my action page :

select group_number,group_name,
sum(case x_flag when 'Y' then 1 else 0 end) as yes_count_total,
sum(case x_flag when 'N' then 1 else 0 end) as No_count_total
from table1 left join table2
on table1.group_number = table2.group_number
where substring(convert(varchar,group_date,101), 1, 2) = '#form.selectmonth#'
and substring(convert(varchar,group_date,101), 7, 4) = '#form.selectyear#'
<cfif form.select1 is not 0>
and site = '#form.select1#'
</cfif>
<cfif form.select2i not 0>
and bnumber = '#form.select2#'
</cfif>
group by group_number,group_name

This gives me the data/output that I want.

What I need to do now is to produce a rolling 12 month display, based on the current month and year selected. Currently, if the month and year selected is March 2008, then that is all I show, the yes_count_total and the no_count_total for that period. What I need to show now is not only data for March 2008, but the yes_count_total and the no_count_total for April 2008, May 2008, etc, , all the way to March 2009. Of course the rolling 12 month period will change based on the month and year selection.

What is the proper way/technique to do this ?
235
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 28, 2008 May 28, 2008
LATEST
My approach would be:

Step 1 - create 2 dates from the form values. If the form gave you Mar 2008, the two dates would be 2008-03-01 and 2009-04-01.

Step 2 - change the where clause in your sql to
where group_date >= date1 and group_date < date2
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources