I've used the DateDiff function but it doesn't work with
SELECT. I started working with a Q of Q and it selects the correct
criteria; however, it's giving me a sum of all the entries and I
can't figure out how to get it to sum for just the entries that
meet the correct criteria. Here's my current code: Thanks!
<cfquery name="ChartQuery" datasource="#Datasource#">
SELECT rcscid, to_char(rcsccontactdte, 'mm/yyyy')"mmyycdte",
rcscname, rcscorg, rcscclosedte, to_char(rcscclosedte,
'mm/yyyy')"mmyycldte", to_char(rcscclosedte, 'mm/dd/yyyy')"cldte",
rcscaction, rcscsolution, to_char(rcscmgmtdte, 'mm/dd/yyyy')"mdte",
rcscbuy, rcscship, rcscfail, rcscycletime
FROM reccusser
ORDER BY rcscid
</cfquery>
<body alink="#6c6c6c" link="navy" vlink="#990000">
<form action="buyAddAction.cfm" method="POST">
<table cellspacing="0" cellpadding="0" border="0"
bgcolor="white" width="100%">
<tr>
<cfinclude template="header.cfm">
<td width="80%"><h1><center>Receiving
Customer Service<br> Run Chart<br></h1>
<h3>
<cfoutput>#DateFormat(Now(),'mm/dd/yyyy')#
<br>
</cfoutput></h3></center>
</tr>
</table>
<table border="2">
<cfset May="05/01/2007">
<cfset May07="05/2007">
<cfset curdte=DateFormat(Now(), "MM/YYYY")>
<cfset date2=DateFormat(Now(), "MM/DD/YYYY")>
<cfset newdte=ChartQuery.mmyycldte>
<cfoutput query="ChartQuery">
<cfset Ctime=datediff("d", May, ChartQuery.cldte)>
<cfif curdte EQ mmyycldte>
<cfquery dbtype="query" name="getdates">
SELECT SUM (ChartQuery.rcscycletime) AS MonthCycle
FROM ChartQuery
WHERE '#May07#' LIKE '#ChartQuery.mmyycldte#'
</cfquery>
<tr>
<td>Show Cur Date: </td>
<td>MMYYY Close Date</td>
<td>Cycle Time: </td>
<td>Close Date</td>
<td>Current Date</td>
<td>Month Cycle</td>
</tr>
<tr>
<td>#curdte#</td>
<td>#ChartQuery.mmyycldte#</td>
<td>#Ctime#</td>
<td>#ChartQuery.cldte#</td>
<td>#date2#</td>
<td>#getdates.MonthCycle#</td>
</tr>
</cfif>
</cfoutput>