Not sure this answers your question, but one I use a lot is datediff, a functional available in both CF and ms sql.
Jenny ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "CF-Newbie" <[email protected]> Sent: Thursday, October 27, 2005 9:40 PM Subject: extracting "between" dates > We figured the very basic part out (that I wrote you about -- To correct, > I deleted the inappropriate code and inserted what I think is the correct > code by copying the "open" code portion and changed the words to "closed" > and "due" throughout as appropriate and that worked for basic searches if > you only used EITHER the Open or the CLosed or the Date Due parameters > alone), but now I realize I need a different array(s) to handle the closed > and the due dates part (I was using the "adateopen" to handle all of it > and that only works if someone is only searching ONE of the date functions > (either open or closed or due, but not in concert with each other) because > if someone wants to search on something opened between x-date and closed > between x-date, it doesn't work (only processes whatever the first > variables are). Any ideas on that? > > 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 > '')) > OR (isDefined("form.toDateClosed") AND (form.toDateClosed IS NOT ''))> > > <cfset aDateOpen[1][1]="tActionItem.dateClosed"> > > <!--- Set the beginning date, if no beginning date is given, set to > 1/1/1900 ---> > <cfif isDefined("form.fromDateClosed") AND (form.fromDateClosed IS NOT > '')> > <cfset aDateOpen[1][2]="#form.fromDateClosed#"> > <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.todateClosed") AND (form.todateClosed IS NOT '')> > <cfset adateOpen[1][3] = "#DateAdd('d',1,form.todateClosed)#"> > <cfelse> > <cfset aDateOpen[1][3]="#Now()#"> > </cfif> > </cfif> > > <cfif (isDefined("form.fromDateDue") AND (form.fromDateDue IS NOT '')) > OR (isDefined("form.toDateDue") AND (form.toDateDue IS NOT ''))> > > <cfset aDateOpen[1][1]="tActionItem.dateDue"> > > <!--- Set the beginning date, if no beginning date is given, set to > 1/1/1900 ---> > <cfif isDefined("form.fromDateDue") AND (form.fromDateDue IS NOT '')> > <cfset aDateOpen[1][2]="#form.fromDateDue#"> > <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.todateDue") AND (form.todateDue IS NOT '')> > <cfset adateOpen[1][3] = > "#DateAdd('d',1,form.todateDue)#"> > <cfelse> > <cfset aDateOpen[1][3]="#Now()#"> > </cfif> > </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 Flash MX Pro from House of Fusion, a Macromedia Authorized Affiliate and support the CF community. http://www.houseoffusion.com/banners/view.cfm?bannerid=57 Message: http://www.houseoffusion.com/lists.cfm/link=i:15:1495 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
