---------------------- Forwarded Message: --------------------- From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Not Subscribed: extracting "between" dates Date: Thu, 27 Oct 2005 17:57:17 +0000
You are not subscribed to the CF-Newbie list with the address [EMAIL PROTECTED] To add this address to your profile, please visit the sign in page at http://www.houseoffusion.com/signin/ Return-Path: <[EMAIL PROTECTED]> Received: from sccrmhc12.comcast.net ([63.240.77.82]) by hof001.houseoffusion.com (Post.Office MTA v3.5.3 release 223 ID# 0-54969U100L100S0V35) with ESMTP id com for <[email protected]>; Thu, 27 Oct 2005 13:58:33 -0400 Received: from 204.127.205.171 ([204.127.205.171]) by comcast.net (sccrmhc12) with SMTP id <2005102717564001200q3h9ue>; Thu, 27 Oct 2005 17:56:45 +0000 Received: from [157.127.124.141] by 204.127.205.171; Thu, 27 Oct 2005 17:56:39 +0000 From: [EMAIL PROTECTED] To: [email protected] Subject: extracting "between" dates Date: Thu, 27 Oct 2005 17:56:39 +0000 Message-Id: <[EMAIL PROTECTED] ast.net> X-Mailer: AT&T Message Center Version 1 (Dec 17 2004) X-Authenticated-Sender: cGxjYXJwZW50ZXJAY29tY2FzdC5uZXQ= Hi! I'm brand new to CF and am trying to extract CLOSED dates from a database. Here is the searchaction page that contains the code. The OPENED code works, but the CLOSED code returns "0 records found." I copied the OPEN code and tweaked it for the closed, thinking it would work the same way (although, maybe an issue is that every record has an OPENed date whereas they all don't yet have closed dates -- just a thought). Could someone give me an idea what's wrong? Thanks! Patti ------------------------------------------------------------------------ <cfif NOT isDefined("FORM.submitted")> <cflocation url="index.cfm"> <cfelse> <cfset qryary = ArrayNew(2)> <cfset aDateOpen = ArrayNew(2)> <cfset aDateOpen[1][1]=''> <cfset i=1> <cfif isDefined("form.ActionItemID") AND (form.ActionItemID IS NOT '')> <cfset qryary[i][1]="tActionItem.ActionItemID"> <cfset qryary[i][2]="#form.ActionItemID#"> <cfset i=#i#+1> </cfif> <cfif isDefined("form.status") AND (form.status IS NOT '')> <cfset qryary[i][1]="tActionItem.ActionClosed"> <cfset qryary[i][2]="#form.status#"> <cfset i=#i#+1> </cfif> <cfif isDefined("form.Assignedto") AND (form.Assignedto IS NOT '')> <cfset qryary[i][1]="tActionItem.Assignedto"> <cfset qryary[i][2]="#form.Assignedto#"> <cfset i=#i#+1> </cfif> <cfif isDefined("form.origination") AND (form.origination IS NOT '')> <cfset qryary[i][1]="tActionItem.origination"> <cfset qryary[i][2]="#form.origination#"> <cfset i=#i#+1> </cfif> <cfif isDefined("form.description") AND (form.description IS NOT '')> <cfset qryary[i][1]="tActionItem.description"> <cfset qryary[i][2]="%#form.description#%"> <cfset i=#i#+1> </cfif> <cfif isDefined("form.rootcause") AND (form.rootcause IS NOT '')> <cfset qryary[i][1]="tActionItem.rootcause"> <cfset qryary[i][2]="#form.rootcause#"> <cfset i=#i#+1> </cfif> <cfif isDefined("form.comments") AND (form.comments IS NOT '')> <cfset qryary[i][1]="tActionItem.comments"> <cfset qryary[i][2]="#form.comments#"> <cfset i=#i#+1> </cfif> <cfif (isDefined("form.fromDateOpened") AND (form.fromDateOpened IS NOT '')) OR (isDefined("form.toDateOpen") AND (form.toDateOpen IS NOT ''))> <cfset aDateOpen[1][1]="tActionItem.dateOpened"> <!--- Set the beginning date, if no beginning date is given, set to 1/1/1900 ---> <cfif isDefined("form.fromDateOpened") AND (form.fromDateOpened IS NOT '')> <cfset aDateOpen[1][2]="#form.fromDateOpened#"> <cfelse> <cfset aDateOpen[1][2]="01/01/1900"> </cfif> <!--- Set the ending date, if no ending date is set, set it to Now ---> <cfif isdefined("form.todateOpen") AND (form.todateOpen IS NOT '')> <cfset adateOpen[1][3] = "#DateAdd('d',1,form.todateOpen)#"> <cfelse> <cfset aDateOpen[1][3]="#Now()#"> </cfif> </cfif> <cfif (isDefined("form.FromDateClosed") AND (form.FromDateClosed IS NOT ''))> <cfset qryary[i][1]="tActionItem.DateClosed"> <cfset qryary[i][2]="%#DateFormat(form.FromDateClosed,"m/d/yyyy")#%"> <cfset i=#i#+1> </cfif> <cfif isDefined("form.FromDateDue") AND (form.FromDateDue IS NOT '')> <cfset qryary[i][1]="tActionItem.DateDue"> <cfset qryary[i][2]="%#DateFormat(form.FromDateDue,"m/d/yyyy")#%"> <cfset i=#i#+1> </cfif> <cfquery name="qReturn" datasource="#application.ds#"> SELECT * FROM tActionItem <cfif aDateOpen[1][1] NEQ ''> WHERE #aDateOpen[1][1]# >= #createodbcdatetime(aDateOpen[1][2])# AND #aDateOpen[1][1]# < #createodbcdatetime(aDateOpen[1][3])# </cfif> <cfloop index="i" from="1" to="#arrayLen(qryary)#"> <cfif i EQ "1" AND aDateOpen[1][1] EQ ''> WHERE <cfelse> AND </cfif> #qryary[i][1]# LIKE '%#qryary[i][2]#%' </cfloop> ORDER BY ActionItemID </cfquery> <!--- <cfquery name="qReturn" datasource="#application.ds#"> SELECT * FROM tActionItem <cfloop index="i" from="1" to="#arrayLen(qryary)#"> <cfif i EQ "1"> WHERE <cfelse> AND </cfif> #qryary[i][1]# LIKE '%#qryary[i][2]#%' </cfloop> ORDER BY ActionItemID </cfquery> ---> <!--- Show Results ---> <table border="0" width="100%"> <tr> <td align="center"><cfinclude template="/applications/centersAI/nav.cfm"></td> </tr> <tr> <td class="redtitle">Search Results</td> </tr> <cfif qReturn.RecordCount EQ 0> <tr> <td> <table class="titleTxt" width="100%"> <tr> <td>Your search generated <BR><cfoutput>#qReturn.RecordCount# Records!</cfoutput><BR><BR> <a href="search.cfm">Try Another Search?</a></td> </tr> </table> </td> </tr> <cfelse> <tr> <td height="81"> <table width="100%"> <tr> <td class="records"> <cfoutput>#qReturn.RecordCount#</cfoutput> Action item records returned </td> </tr> </table> </td> </tr> <tr> <td> <table width="100%"> <tr> <td> <cfoutput query="qReturn"> <cfif qReturn.CurrentRow MOD 2 IS 1> <cfset bgcolor="##CCCCCC"> <cfelse> <cfset bgcolor="##FFFFFF"> </cfif> <!--- Display the results of the search findings ---> <table width="100%" cellspacing="0" cellpadding="4" border="0"> <!--- Color changing from White to Grey of the bars to make it easier to read ---> <tr class="content" bgcolor="#variables.bgcolor#"> <td colspan="6" class="titlecontent"> Action Item ID ##: #qreturn.ActionItemID#</td> </tr> <tr class="content" bgcolor="#variables.bgcolor#"> <td width="16%"><span class="labelcontent">Status:</span><br> <cfif qreturn.ActionClosed EQ 0>Open<cfelse>Closed </cfif></td> <td><span class="labelcontent">Root Cause:</span><br> #qreturn.rootcause#</td> <td width="20%"><span class="labelcontent">Origination:</span><br> #qreturn.origination#</td> <td width="16%"><span class="labelcontent">Date Opened:</span><br> #DateFormat(qreturn.dateOpened,"dd-mmm-yy")#</td> <td width="16%"><span class="labelcontent">Date Due:</span><br> #DateFormat(qreturn.DateDue,"dd-mmm-yy")#</td> <td width="16%"><span class="labelcontent">Date Closed:</span><br> #DateFormat(qreturn.DateClosed,"dd-mmm-yy")#</td> </tr> <tr class="content" bgcolor="#variables.bgcolor#"> <td colspan="2"><span class="labelcontent">Description:</span><br> #qreturn.description#</td> <td colspan="2"><span class="labelcontent">Comments:</span><br> #qreturn.comments#</td> <td colspan="2"><span class="labelcontent">Assigned to:</span><br> #fTitleCase(qreturn.Assignedto)#</td> </tr> <tr class="content" bgcolor="#variables.bgcolor#"> <td colspan="6"><hr width="100%" color="##990000"></td> </tr> </table> </cfoutput> </td> </tr> </table> </td> </tr> </cfif> </table> </cfif> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Purchase RoboHelp from House of Fusion, a Macromedia Authorized Affiliate and support the CF community. http://www.houseoffusion.com/banners/view.cfm?bannerid=59 Message: http://www.houseoffusion.com/lists.cfm/link=i:15:1491 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/15 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:15 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
