freelanceprogrammers.org Forum Index » Cold Fusion

What`s missing in this simple code


View user's profile Post To page top
dansox Posted: Fri Oct 07, 2005 5:06 am


Joined: 07 Oct 2005

Posts: 3
What`s missing in this simple code
Below is my current code for grouping monthly sales by month. The
problem is they are currently displayed starting with month 1 and
ending with month 12. Month`s 11 and 12 are obviously empty results
since we`re in October. However, I want the code to start with the
current month and go backwards 12 months but I can`t figure out how
to do that. Any ideas?


Monthly Totals:<p>

<table border="0" width="25%">

<CFLOOP FROM="1" TO="12" INDEX="Mon">

<CFSET todaysdate = Now()>

<cfquery name="list" datasource="lilleys">
SELECT Sum(Jobs.subtotal) AS SumOfsubtotal
FROM Jobs
WHERE
Month(jobdate) = <CFOUTPUT>#Mon#</CFOUTPUT>
AND
Year(jobdate) = 2005;
</cfquery>


<cfoutput query="list">

<cfset monthlylength = (#sumofsubtotal#) / 50>

<tr>
<td>#Mon#:</td>
<td><img src="/admin/images/chart.gif" align="middle"
width="#monthlylength#"
height="20">&nbsp;&nbsp;&nbsp;#LSCurrencyFormat(sumofsubtotal)#</td>
</tr>

</cfoutput>




</CFLOOP>
</table>
Reply with quote
Send private message
View user's profile Post To page top
kompwizard Posted: Fri Oct 07, 2005 9:11 pm


Joined: 07 Oct 2005

Posts: 2
What`s missing in this simple code
Hi Dan,

I suggest you create a comma delimited list of mm/yyyy structure. You
could then use this list in your cfloop, referencing it in each step
so that you can have the correct mm and yyyy references for your
query. I think the following should work.

<cfset currentMonth = Month(now())>
<cfset currentYear = Year(now())>
<cfset lastYear = currentYear -1>
<cfset dateStrings = "">
<cfif currentMonth eq 12>
<cfset firstMonth = 1>
<cfloop index="Month" from="#firstMonth#" to="12">
<cfset datestrings = dateStrings & #Month# & "/" & #LastYear# & ",">
</cfloop>
<cfelse>
<cfset firstMonth = currentmonth + 1>
<cfloop index="Month" from="#firstMonth#" to="12">
<cfset datestrings = dateStrings & #Month# & "/" & #LastYear# & ",">
</cfloop>
<cfset secondLoop = 12 - ListLen(dateStrings)>
<cfloop index="Month" from="1" to="#secondLoop#">
<cfset datestrings = dateStrings & #Month# & "/" & #currentYear# & ",">
</cfloop>
</cfif>

You may be able to do it in fewer steps. I`m really in the best
readability and maintainability camp myself. You should be able to use
the dateStrings list for your cfloop from the example above.

Later...

Lee


--- In cold_fusion@yahoogroups.com, "Dan" <ddecosta@m...> wrote:
>
> Below is my current code for grouping monthly sales by month. The
> problem is they are currently displayed starting with month 1 and
> ending with month 12. Month`s 11 and 12 are obviously empty results
> since we`re in October. However, I want the code to start with the
> current month and go backwards 12 months but I can`t figure out how
> to do that. Any ideas?
>
>
> Monthly Totals:<p>
>
> <table border="0" width="25%">
>
> <CFLOOP FROM="1" TO="12" INDEX="Mon">
>
> <CFSET todaysdate = Now()>
>
> <cfquery name="list" datasource="lilleys">
> SELECT Sum(Jobs.subtotal) AS SumOfsubtotal
> FROM Jobs
> WHERE
> Month(jobdate) = <CFOUTPUT>#Mon#</CFOUTPUT>
> AND
> Year(jobdate) = 2005;
> </cfquery>
>
>
> <cfoutput query="list">
>
> <cfset monthlylength = (#sumofsubtotal#) / 50>
>
> <tr>
> <td>#Mon#:</td>
> <td><img src="/admin/images/chart.gif" align="middle"
> width="#monthlylength#"
> height="20">&nbsp;&nbsp;&nbsp;#LSCurrencyFormat(sumofsubtotal)#</td>
> </tr>
>
> </cfoutput>
>
>
>
>
> </CFLOOP>
> </table>
>
Reply with quote
Send private message
View user's profile Post To page top
kompwizard Posted: Fri Oct 07, 2005 9:13 pm


Joined: 07 Oct 2005

Posts: 2
What`s missing in this simple code
Ooops!!

Typo in my first loop. The varible referenced should be #currentYear#,
not #lastYear#. That`s what I get for cutting and pasting.

Lee

--- In cold_fusion@yahoogroups.com, "Komputer Wizard" <lee@n...> wrote:
>
> Hi Dan,
>
> I suggest you create a comma delimited list of mm/yyyy structure. You
> could then use this list in your cfloop, referencing it in each step
> so that you can have the correct mm and yyyy references for your
> query. I think the following should work.
>
> <cfset currentMonth = Month(now())>
> <cfset currentYear = Year(now())>
> <cfset lastYear = currentYear -1>
> <cfset dateStrings = "">
> <cfif currentMonth eq 12>
> <cfset firstMonth = 1>
> <cfloop index="Month" from="#firstMonth#" to="12">
> <cfset datestrings = dateStrings & #Month# & "/" & #LastYear# & ",">
> </cfloop>
> <cfelse>
> <cfset firstMonth = currentmonth + 1>
> <cfloop index="Month" from="#firstMonth#" to="12">
> <cfset datestrings = dateStrings & #Month# & "/" & #LastYear# & ",">
> </cfloop>
> <cfset secondLoop = 12 - ListLen(dateStrings)>
> <cfloop index="Month" from="1" to="#secondLoop#">
> <cfset datestrings = dateStrings & #Month# & "/" & #currentYear# &
",">
> </cfloop>
> </cfif>
>
> You may be able to do it in fewer steps. I`m really in the best
> readability and maintainability camp myself. You should be able to use
> the dateStrings list for your cfloop from the example above.
>
> Later...
>
> Lee
>
>
> --- In cold_fusion@yahoogroups.com, "Dan" <ddecosta@m...> wrote:
> >
> > Below is my current code for grouping monthly sales by month. The
> > problem is they are currently displayed starting with month 1 and
> > ending with month 12. Month`s 11 and 12 are obviously empty results
> > since we`re in October. However, I want the code to start with the
> > current month and go backwards 12 months but I can`t figure out how
> > to do that. Any ideas?
> >
> >
> > Monthly Totals:<p>
> >
> > <table border="0" width="25%">
> >
> > <CFLOOP FROM="1" TO="12" INDEX="Mon">
> >
> > <CFSET todaysdate = Now()>
> >
> > <cfquery name="list" datasource="lilleys">
> > SELECT Sum(Jobs.subtotal) AS SumOfsubtotal
> > FROM Jobs
> > WHERE
> > Month(jobdate) = <CFOUTPUT>#Mon#</CFOUTPUT>
> > AND
> > Year(jobdate) = 2005;
> > </cfquery>
> >
> >
> > <cfoutput query="list">
> >
> > <cfset monthlylength = (#sumofsubtotal#) / 50>
> >
> > <tr>
> > <td>#Mon#:</td>
> > <td><img src="/admin/images/chart.gif" align="middle"
> > width="#monthlylength#"
> > height="20">&nbsp;&nbsp;&nbsp;#LSCurrencyFormat(sumofsubtotal)#</td>
> > </tr>
> >
> > </cfoutput>
> >
> >
> >
> >
> > </CFLOOP>
> > </table>
> >
>
Reply with quote
Send private message
View user's profile Post To page top
sandersfred Posted: Mon Oct 10, 2005 3:03 am


Joined: 02 May 2005

Posts: 11
What`s missing in this simple code
from=12 to=1 step=-1 in your cfloop tag.

even better would be to build a complete query that actually does all this for
you and then you can "group" in your cfquery tag to do all the work for you,
would be less typing and much more efficient.

Fred

On October 6, 2005 08:06 pm, Dan scribbled:
> Below is my current code for grouping monthly sales by month. The
> problem is they are currently displayed starting with month 1 and
> ending with month 12. Month`s 11 and 12 are obviously empty results
> since we`re in October. However, I want the code to start with the
> current month and go backwards 12 months but I can`t figure out how
> to do that. Any ideas?
>
>
> Monthly Totals:<p>
>
> <table border="0" width="25%">
>
> <CFLOOP FROM="1" TO="12" INDEX="Mon">
>
> <CFSET todaysdate = Now()>
>
> <cfquery name="list" datasource="lilleys">
> SELECT Sum(Jobs.subtotal) AS SumOfsubtotal
> FROM Jobs
> WHERE
> Month(jobdate) = <CFOUTPUT>#Mon#</CFOUTPUT>
> AND
> Year(jobdate) = 2005;
> </cfquery>
>
>
> <cfoutput query="list">
>
> <cfset monthlylength = (#sumofsubtotal#) / 50>
>
> <tr>
> <td>#Mon#:</td>
> <td><img src="/admin/images/chart.gif" align="middle"
> width="#monthlylength#"
> height="20">&nbsp;&nbsp;&nbsp;#LSCurrencyFormat(sumofsubtotal)#</td>
> </tr>
>
> </cfoutput>
>
>
>
>
> </CFLOOP>
> </table>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
Reply with quote
Send private message
View user's profile Post To page top
dansox Posted: Mon Oct 10, 2005 3:24 am


Joined: 07 Oct 2005

Posts: 3
What`s missing in this simple code
It`s not 12-1 that I need.  It`s the last 12 months.  Does that make a difference?
DanLilley`s Limousine207-883-6020http://www.lilleyslimousine.com

----- Original Message -----
From: Fred T. Sanders
To: cold_fusion@yahoogroups.com
Sent: Sunday, October 09, 2005 6:03 PM
Subject: Re: [cold_fusion] What`s missing in this simple code
from=12 to=1 step=-1 in your cfloop tag.even better would be to build a complete query that actually does all this for you and then you can "group" in your cfquery tag to do all the work for you, would be less typing and much more efficient.FredOn October 6, 2005 08:06 pm, Dan scribbled:> Below is my current code for grouping monthly sales by month.  The> problem is they are currently displayed starting with month 1 and> ending with month 12.  Month`s 11 and 12 are obviously empty results> since we`re in October.  However, I want the code to start with the> current month and go backwards 12 months but I can`t figure out how> to do that.  Any ideas?>>> Monthly Totals:<p>>> <table border="0" width="25%">>> <CFLOOP FROM="1" TO="12" INDEX="Mon">>>  <CFSET todaysdate = Now()>>>  <cfquery name="list" datasource="lilleys">>  SELECT Sum(Jobs.subtotal) AS SumOfsubtotal>  FROM Jobs>  WHERE>  Month(jobdate) = <CFOUTPUT>#Mon#</CFOUTPUT>>  AND>  Year(jobdate) = 2005;>  </cfquery>>>>  <cfoutput query="list">>> <cfset monthlylength = (#sumofsubtotal#) / 50>>> <tr>> <td>#Mon#:</td>> <td><img src="/admin/images/chart.gif" align="middle"> width="#monthlylength#"> height="20">&nbsp;&nbsp;&nbsp;#LSCurrencyFormat(sumofsubtotal)#</td>> </tr>>> </cfoutput>>>>>> </CFLOOP>>  </table>>>>>>>> Yahoo! Groups Links>>>
Reply with quote
Send private message
View user's profile Post To page top
sandersfred Posted: Mon Oct 10, 2005 4:25 am


Joined: 02 May 2005

Posts: 11
What`s missing in this simple code
Ah, okay that`s different. Then you really should use sql for the data
collection. Before I go into how I would probably do it.

Your query leads me to believe that you want to go back 12 months from the
month the query is being run in. But only if the year is still 2005. Any
particular reason and you know your going to have to rewrite it next year if
the app lasts that long. :)

Fred



On October 9, 2005 06:24 pm, Dan DeCosta scribbled:
> It`s not 12-1 that I need. It`s the last 12 months. Does that make a
> difference?
>
> Dan
> Lilley`s Limousine
> 207-883-6020
> http://www.lilleyslimousine.com
>
> ----- Original Message -----
> From: Fred T. Sanders
> To: cold_fusion@yahoogroups.com
> Sent: Sunday, October 09, 2005 6:03 PM
> Subject: Re: [cold_fusion] What`s missing in this simple code
>
>
> from=12 to=1 step=-1 in your cfloop tag.
>
> even better would be to build a complete query that actually does all
> this for you and then you can "group" in your cfquery tag to do all the
> work for you, would be less typing and much more efficient.
>
> Fred
>
> On October 6, 2005 08:06 pm, Dan scribbled:
> > Below is my current code for grouping monthly sales by month. The
> > problem is they are currently displayed starting with month 1 and
> > ending with month 12. Month`s 11 and 12 are obviously empty results
> > since we`re in October. However, I want the code to start with the
> > current month and go backwards 12 months but I can`t figure out how
> > to do that. Any ideas?
> >
> >
> > Monthly Totals:<p>
> >
> > <table border="0" width="25%">
> >
> > <CFLOOP FROM="1" TO="12" INDEX="Mon">
> >
> > <CFSET todaysdate = Now()>
> >
> > <cfquery name="list" datasource="lilleys">
> > SELECT Sum(Jobs.subtotal) AS SumOfsubtotal
> > FROM Jobs
> > WHERE
> > Month(jobdate) = <CFOUTPUT>#Mon#</CFOUTPUT>
> > AND
> > Year(jobdate) = 2005;
> > </cfquery>
> >
> >
> > <cfoutput query="list">
> >
> > <cfset monthlylength = (#sumofsubtotal#) / 50>
> >
> > <tr>
> > <td>#Mon#:</td>
> > <td><img src="/admin/images/chart.gif" align="middle"
> > width="#monthlylength#"
> > height="20">&nbsp;&nbsp;&nbsp;#LSCurrencyFormat(sumofsubtotal)#</td>
> > </tr>
> >
> > </cfoutput>
> >
> >
> >
> >
> > </CFLOOP>
> > </table>
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
>
> ---------------------------------------------------------------------------
>--- YAHOO! GROUPS LINKS
>
> a.. Visit your group "cold_fusion" on the web.
>
> b.. To unsubscribe from this group, send an email to:
> cold_fusion-unsubscribe@yahoogroups.com
>
> c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
>
>
> ---------------------------------------------------------------------------
>---
Reply with quote
Send private message
View user's profile Post To page top
dansox Posted: Mon Oct 10, 2005 4:28 am


Joined: 07 Oct 2005

Posts: 3
What`s missing in this simple code
Should be a way to do it no matter what year it is.
 
I want to display current month total, last months total, back 12 months.
DanLilley`s Limousine207-883-6020http://www.lilleyslimousine.com

----- Original Message -----
From: Fred T. Sanders
To: cold_fusion@yahoogroups.com
Sent: Sunday, October 09, 2005 7:25 PM
Subject: Re: [cold_fusion] What`s missing in this simple code
Ah, okay that`s different. Then you really should use sql for the data collection.  Before I go into how I would probably do it.Your query leads me to believe that you want to go back 12 months from the month the query is being run in.  But only if the year is still 2005.  Any particular reason and you know your going to have to rewrite it next year if the app lasts that long. :)FredOn October 9, 2005 06:24 pm, Dan DeCosta scribbled:> It`s not 12-1 that I need.  It`s the last 12 months.  Does that make a> difference?>> Dan> Lilley`s Limousine> 207-883-6020> http://www.lilleyslimousine.com>>   ----- Original Message ----->   From: Fred T. Sanders>   To: cold_fusion@yahoogroups.com>   Sent: Sunday, October 09, 2005 6:03 PM>   Subject: Re: [cold_fusion] What`s missing in this simple code>>>   from=12 to=1 step=-1 in your cfloop tag.>>   even better would be to build a complete query that actually does all> this for you and then you can "group" in your cfquery tag to do all the> work for you, would be less typing and much more efficient.>>   Fred>>   On October 6, 2005 08:06 pm, Dan scribbled:>   > Below is my current code for grouping monthly sales by month.  The>   > problem is they are currently displayed starting with month 1 and>   > ending with month 12.  Month`s 11 and 12 are obviously empty results>   > since we`re in October.  However, I want the code to start with the>   > current month and go backwards 12 months but I can`t figure out how>   > to do that.  Any ideas?>   >>   >>   > Monthly Totals:<p>>   >>   > <table border="0" width="25%">>   >>   > <CFLOOP FROM="1" TO="12" INDEX="Mon">>   >>   >  <CFSET todaysdate = Now()>>   >>   >  <cfquery name="list" datasource="lilleys">>   >  SELECT Sum(Jobs.subtotal) AS SumOfsubtotal>   >  FROM Jobs>   >  WHERE>   >  Month(jobdate) = <CFOUTPUT>#Mon#</CFOUTPUT>>   >  AND>   >  Year(jobdate) = 2005;>   >  </cfquery>>   >>   >>   >  <cfoutput query="list">>   >>   > <cfset monthlylength = (#sumofsubtotal#) / 50>>   >>   > <tr>>   > <td>#Mon#:</td>>   > <td><img src="/admin/images/chart.gif" align="middle">   > width="#monthlylength#">   > height="20">&nbsp;&nbsp;&nbsp;#LSCurrencyFormat(sumofsubtotal)#</td>>   > </tr>>   >>   > </cfoutput>>   >>   >>   >>   >>   > </CFLOOP>>   >  </table>>   >>   >>   >>   >>   >>   >>   > Yahoo! Groups Links>> --------------------------------------------------------------------------->--- YAHOO! GROUPS LINKS>>     a..  Visit your group "cold_fusion" on the web.>>     b..  To unsubscribe from this group, send an email to:>      cold_fusion-unsubscribe@yahoogroups.com>>     c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of> Service.>>> --------------------------------------------------------------------------->---
Reply with quote
Send private message
View user's profile Post To page top
sandersfred Posted: Mon Oct 10, 2005 4:39 am


Joined: 02 May 2005

Posts: 11
What`s missing in this simple code
k, was just checking since, it was a condition of the query.

Fred

On October 9, 2005 07:28 pm, Dan DeCosta scribbled:
> Should be a way to do it no matter what year it is.
>
> I want to display current month total, last months total, back 12 months.
>
> Dan
> Lilley`s Limousine
> 207-883-6020
> http://www.lilleyslimousine.com
>
> ----- Original Message -----
> From: Fred T. Sanders
> To: cold_fusion@yahoogroups.com
> Sent: Sunday, October 09, 2005 7:25 PM
> Subject: Re: [cold_fusion] What`s missing in this simple code
>
>
> Ah, okay that`s different. Then you really should use sql for the data
> collection. Before I go into how I would probably do it.
>
> Your query leads me to believe that you want to go back 12 months from
> the month the query is being run in. But only if the year is still 2005.
> Any particular reason and you know your going to have to rewrite it next
> year if the app lasts that long. :)
>
> Fred
>
> On October 9, 2005 06:24 pm, Dan DeCosta scribbled:
> > It`s not 12-1 that I need. It`s the last 12 months. Does that make a
> > difference?
> >
> > Dan
> > Lilley`s Limousine
> > 207-883-6020
> > http://www.lilleyslimousine.com
> >
> > ----- Original Message -----
> > From: Fred T. Sanders
> > To: cold_fusion@yahoogroups.com
> > Sent: Sunday, October 09, 2005 6:03 PM
> > Subject: Re: [cold_fusion] What`s missing in this simple code
> >
> >
> > from=12 to=1 step=-1 in your cfloop tag.
> >
> > even better would be to build a complete query that actually does all
> > this for you and then you can "group" in your cfquery tag to do all the
> > work for you, would be less typing and much more efficient.
> >
> > Fred
> >
> > On October 6, 2005 08:06 pm, Dan scribbled:
> > > Below is my current code for grouping monthly sales by month. The
> > > problem is they are currently displayed starting with month 1 and
> > > ending with month 12. Month`s 11 and 12 are obviously empty
> > > results since we`re in October. However, I want the code to start
> > > with the current month and go backwards 12 months but I can`t
> > > figure out how to do that. Any ideas?
> > >
> > >
> > > Monthly Totals:<p>
> > >
> > > <table border="0" width="25%">
> > >
> > > <CFLOOP FROM="1" TO="12" INDEX="Mon">
> > >
> > > <CFSET todaysdate = Now()>
> > >
> > > <cfquery name="list" datasource="lilleys">
> > > SELECT Sum(Jobs.subtotal) AS SumOfsubtotal
> > > FROM Jobs
> > > WHERE
> > > Month(jobdate) = <CFOUTPUT>#Mon#</CFOUTPUT>
> > > AND
> > > Year(jobdate) = 2005;
> > > </cfquery>
> > >
> > >
> > > <cfoutput query="list">
> > >
> > > <cfset monthlylength = (#sumofsubtotal#) / 50>
> > >
> > > <tr>
> > > <td>#Mon#:</td>
> > > <td><img src="/admin/images/chart.gif" align="middle"
> > > width="#monthlylength#"
> > > height="20">&nbsp;&nbsp;&nbsp;#LSCurrencyFormat(sumofsubtotal)#</td
> > >> </tr>
> > >
> > > </cfoutput>
> > >
> > >
> > >
> > >
> > > </CFLOOP>
> > > </table>
> > >
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> >
> > -----------------------------------------------------------------------
> >---- --- YAHOO! GROUPS LINKS
> >
> > a.. Visit your group "cold_fusion" on the web.
> >
> > b.. To unsubscribe from this group, send an email to:
> > cold_fusion-unsubscribe@yahoogroups.com
> >
> > c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> > Service.
> >
> >
> > -----------------------------------------------------------------------
> >---- ---
>
> SPONSORED LINKS Cold fusion development Cold fusion web development
> Cold fusion hosting Cold fusion mx hosting Cold fusion mx web hosting
> Cold fusion web hosting
>
>
> ---------------------------------------------------------------------------
>--- YAHOO! GROUPS LINKS
>
> a.. Visit your group "cold_fusion" on the web.
>
> b.. To unsubscribe from this group, send an email to:
> cold_fusion-unsubscribe@yahoogroups.com
>
> c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
>
>
> ---------------------------------------------------------------------------
>---
Reply with quote
Send private message
View user's profile Post To page top
sandersfred Posted: Tue Oct 11, 2005 11:02 am


Joined: 02 May 2005

Posts: 11
What`s missing in this simple code
Sorry for the delay, its Thanksgiving in Canada, and I forgot (not actually
Canadian so I keep thinking that its actually in November). After finishing
this up, and deciding to just do the logic in CF mainly because I have no
idea what your db back end is I`ve discovered that it looks enough like Lee`s
code that there`s really no point in posting it. I`ll hold on to it anyway
for a bit though.

Fred


On October 9, 2005 07:28 pm, you scribbled:
> Should be a way to do it no matter what year it is.
>
> I want to display current month total, last months total, back 12 months.
>
> Dan
> Lilley`s Limousine
> 207-883-6020
> http://www.lilleyslimousine.com
>
> ----- Original Message -----
> From: Fred T. Sanders
> To: cold_fusion@yahoogroups.com
> Sent: Sunday, October 09, 2005 7:25 PM
> Subject: Re: [cold_fusion] What`s missing in this simple code
>
>
> Ah, okay that`s different. Then you really should use sql for the data
> collection. Before I go into how I would probably do it.
>
> Your query leads me to believe that you want to go back 12 months from
> the month the query is being run in. But only if the year is still 2005.
> Any particular reason and you know your going to have to rewrite it next
> year if the app lasts that long. :)
>
> Fred
>
> On October 9, 2005 06:24 pm, Dan DeCosta scribbled:
> > It`s not 12-1 that I need. It`s the last 12 months. Does that make a
> > difference?
> >
> > Dan
> > Lilley`s Limousine
> > 207-883-6020
> > http://www.lilleyslimousine.com
> >
> > ----- Original Message -----
> > From: Fred T. Sanders
> > To: cold_fusion@yahoogroups.com
> > Sent: Sunday, October 09, 2005 6:03 PM
> > Subject: Re: [cold_fusion] What`s missing in this simple code
> >
> >
> > from=12 to=1 step=-1 in your cfloop tag.
> >
> > even better would be to build a complete query that actually does all
> > this for you and then you can "group" in your cfquery tag to do all the
> > work for you, would be less typing and much more efficient.
> >
> > Fred
> >
> > On October 6, 2005 08:06 pm, Dan scribbled:
> > > Below is my current code for grouping monthly sales by month. The
> > > problem is they are currently displayed starting with month 1 and
> > > ending with month 12. Month`s 11 and 12 are obviously empty
> > > results since we`re in October. However, I want the code to start
> > > with the current month and go backwards 12 months but I can`t
> > > figure out how to do that. Any ideas?
> > >
> > >
> > > Monthly Totals:<p>
> > >
> > > <table border="0" width="25%">
> > >
> > > <CFLOOP FROM="1" TO="12" INDEX="Mon">
> > >
> > > <CFSET todaysdate = Now()>
> > >
> > > <cfquery name="list" datasource="lilleys">
> > > SELECT Sum(Jobs.subtotal) AS SumOfsubtotal
> > > FROM Jobs
> > > WHERE
> > > Month(jobdate) = <CFOUTPUT>#Mon#</CFOUTPUT>
> > > AND
> > > Year(jobdate) = 2005;
> > > </cfquery>
> > >
> > >
> > > <cfoutput query="list">
> > >
> > > <cfset monthlylength = (#sumofsubtotal#) / 50>
> > >
> > > <tr>
> > > <td>#Mon#:</td>
> > > <td><img src="/admin/images/chart.gif" align="middle"
> > > width="#monthlylength#"
> > > height="20">&nbsp;&nbsp;&nbsp;#LSCurrencyFormat(sumofsubtotal)#</td
> > >> </tr>
> > >
> > > </cfoutput>
> > >
> > >
> > >
> > >
> > > </CFLOOP>
> > > </table>
> > >
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> >
> > -----------------------------------------------------------------------
> >---- --- YAHOO! GROUPS LINKS
> >
> > a.. Visit your group "cold_fusion" on the web.
> >
> > b.. To unsubscribe from this group, send an email to:
> > cold_fusion-unsubscribe@yahoogroups.com
> >
> > c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> > Service.
> >
> >
> > -----------------------------------------------------------------------
> >---- ---
>
> SPONSORED LINKS Cold fusion development Cold fusion web development
> Cold fusion hosting Cold fusion mx hosting Cold fusion mx web hosting
> Cold fusion web hosting
>
>
> ---------------------------------------------------------------------------
>--- YAHOO! GROUPS LINKS
>
> a.. Visit your group "cold_fusion" on the web.
>
> b.. To unsubscribe from this group, send an email to:
> cold_fusion-unsubscribe@yahoogroups.com
>
> c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
>
>
> ---------------------------------------------------------------------------
>---
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help