Listing 1

<cfcomponent>
	<CFSET thecurrenttime = Now()>
	<cffunction name="collectSearchTerm" access="public" output="false">
		<cfargument name="thesearchterm" type="string" required="true" default="failure">
		<cfargument name="thesearchdate" type="date" required="true"
		 default="#CreateODBCDateTime(thecurrenttime)#">
		<CFQUERY datasource="#request.dsn#" username="#request.dsnusername#"
		 password="#request.dsnpassword#">
		INSERT INTO tbl_searchterms (thesearchterm,thesearchdate)
		VALUES ('#arguments.thesearchterm#',#arguments.thesearchdate#)
		</CFQUERY>
	</cffunction>
	<cffunction name="getSearchTerms" access="remote" returntype="query" output="false">
		<CFARGUMENT name="theenddate" default="#thecurrenttime#">
		<CFARGUMENT name="thestartdate" default="#DateAdd('d',-7,Now())#">
<CFQUERY name="searchcount" datasource="#request.dsn#" username="#request.dsnusername#"
		 password="#request.dsnpassword#">
		SELECT thesearchterm, COUNT(thesearchterm) AS TheCount
		FROM tbl_searchterms
		WHERE thesearchdate BETWEEN #CreateODBCDate(arguments.thestartdate)# AND
		 #CreateODBCDate(DateAdd('d',1,arguments.theenddate))#
		GROUP BY thesearchterm
		ORDER BY TheCount DESC, thesearchterm
		</CFQUERY>
		<CFRETURN searchcount>
	</cffunction>
	<cffunction name="displayMailReport" access="remote" output="true">
		<CFARGUMENT name="theenddate" default="#thecurrenttime#">
		<CFARGUMENT name="thestartdate" default="#DateAdd('d',-7,Now())#">
		<CFARGUMENT name="themailto" default="#request.mailto#">
		<CFARGUMENT name="fromform" default="no">
		<CFINVOKE method="getSearchTerms" returnvariable="searchcount"
		 argumentcollection="#ARGUMENTS#">
		<div style="width:500px;font-family:Verdana, Arial, Helvetica,
		 sans-serif;font-size:12px;">
		<CFOUTPUT>
		<CFIF arguments.fromform is "yes">
			<a href="javascript: history.go(-1)">< - Back to form</a><br><br>
		</CFIF>
		It is now: #dateformat(now(),"mm.dd.yyyy")# #timeformat(now(),"HH:mm")#<br>
		For the domain #request.thissite# - <br>
		Search terms ranked by frequency of request, for dates beginning
		 #dateformat(arguments.thestartdate,"mm.d.yyyy")# and going through
<CFIF #DateCompare(createODBCdate(theenddate),createODBCdate(thecurrenttime))# IS 0>
			#timeformat(thecurrenttime,"HH:mm")#  local server time
		</CFIF> #dateformat(arguments.theenddate,"mm.d.yyyy")#:<br>
		<br>
		</CFOUTPUT>
		<table width=400 cellpadding=2 cellspacing=0 border=1>
		<tr>
		<td valign="top" align="left" width=80 bgcolor="silver">Count</td><td valign="top"
		 align="left" bgcolor="silver">Search term</td>
		</tr>
		<CFOUTPUT query="searchcount">
		<tr>
		<td valign="top" align="right">#thecount#</td><td valign="top"
		 align="left">#thesearchterm#</td>
		</tr>
		</CFOUTPUT>
		</table>
		</div>
		<CFIF #arguments.themailto# IS NOT "">
			<cfmail
			to="#arguments.themailto#"
			from="#request.mailfrom#"
			server="#request.mailserver#"
			subject="Search terms report for #request.thissite#"
			type="html"
			query="searchcount"
			>
			<div style="width:400;font-family:Verdana, Arial, Helvetica,
			 sans-serif;font-size:12px;">
			For the web site #request.thissite# -<br>
			Here are the search terms visitors entered into the site's internal search facility,
			 ranked by frequency of request, for dates beginning
			  #dateformat(arguments.thestartdate,"mm.d.yyyy")# and going through
			  <CFIF #DateCompare(createODBCdate(theenddate),createODBCdate(thecurrenttime))# IS 0>
				#timeformat(thecurrenttime,"HH:mm")#  local server time
			</CFIF> #dateformat(arguments.theenddate,"mm.d.yyyy")#:<br>
			<br>
			<table width=400 cellpadding=2 cellspacing=0 border=1 style="font-family:Verdana,
			 Arial, Helvetica, sans-serif;font-size:12px">
			<tr>
			<td valign="top" align="left" width=80
			 bgcolor="silver"><strong>Count</strong></td><td valign="top" align="left"
			  bgcolor="silver"><strong>Search term</strong></td>
			</tr>
			<CFOUTPUT>
			<tr>
			<td valign="top" align="right">#thecount#</td><td valign="top"
			 align="left">#thesearchterm#</td>
			</tr>
			</CFOUTPUT>
			</table>
			<em>Generated server local time: #dateformat(now(),"mm.dd.yyyy")#
			 #timeformat(now(),"HH:mm")#</em><br>
			<br>
			</div>
			</cfmail>
		</CFIF>
		</cffunction>
</cfcomponent>


Listing 2

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 <http://www.w3.org/TR/html4/loose.dtd>"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Verity Report Input Form</title>
</head>
<body>
<CFSET thecurrenttime = Now()>
<cfparam name="form.theenddate" default="#thecurrenttime#">
<cfparam name="form.thestartdate" default="#DateAdd('d',-7,Now())#">
<cfparam name="form.themailto" default="">
<div style="width:400px">
<CFOUTPUT>
<CFForm action="/mycfcmapping/verityreport.cfc" method="post">
Display the search terms used on this web site from:<br>
<CFInput type="text" size="20" name="thestartdate"
 value="#DateFormat(form.thestartdate,'mm/dd/yyyy')#" REQUIRED="yes" VALIDATE="date" MESSAGE="For
  start date, please enter date in the format mm/dd/yyyy, example 10/09/2004."><br>
<em>Enter a valid date as the start date. Example: 10/09/2004.</em><br>
<br>
to:<br>
<CFinput type="text" size="20" name="theenddate"
 value="#DateFormat(form.theenddate,'mm/dd/yyyy')#" REQUIRED="yes"  VALIDATE="date" MESSAGE="For end
  date, please enter date format mm/dd/yyyy, example 10/16/2004."><br>
<em>Enter a valid date as the end date. Example: 10/24/2004.</em><br>
<br>
Also email the results to:<br>
<CFinput type="text" size="50" name="themailto" value="#form.themailto#"><br>
<em>If you would like these results emailed, enter the email addresses here, separated by commas.</em><br>
<br>
<input type="hidden" name="fromform" value="yes">
<input type="hidden" name="method" value="displaymailreport">
<input type="submit" value="Make the Report">
</CFForm>
</CFOUTPUT>
</div>
</body>
</html>