473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Need help with ColdFusion search criteria - CreateODBCDate

I want to enable a user to enter a start and end date to define the period they want to search for records of members who joined on certain dates. Funny thing is...I've got it to work half of the time. For e.g. I have 4 records between 26/10/2005 and 1/08/2006. When I enter 01/01/2005 as startDate and 31/08/2006 as endDate, I get the 4 records. However, if I alter the endDate to 01/09/2006 I get every record in the database!!!??? Why's this? I can't get my head around it!

Here's my code:
First the code for the form the user input the search criteria on:

<html>
<body>
<FORM action="memberJDateSearch.cfm" method="post">

<p>Start Date: <input type="text" name="startDate">
<br>End Date: <input type="text" name="endDate">
<input type="reset" value="Clear">
<input type="submit" value="Submit">
</FORM>

</body>
</html>

Simple enough. Now the code for the process and display page:

<html>
<body>


<cfquery name="memberJDateSearch" datasource="jpkelle2-access">
SELECT *
From members
WHERE ((joinDate BETWEEN #CreateODBCDate(startDate)# AND #CreateODBCDate(endDate)#))

</cfquery>

<table border=1 bgcolor="beige" cellpadding="3" cellspacing="0">
<tr>
<th>Member ID</th>
<th>Name</th>
<th>Sex</th>
<th>Date of Birth</th>
<th>Address</th>
<th>Email</th>
<th>Date Joined</th>
</tr>




<CFOUTPUT Query="memberJDateSearch">

<tr>
<td><center>#memberID#<center></td>
<td width="15%">#forename# #initial# #surname#</td>
<td>#sex#</td>
<td width="10%">#disp('#dob#')#</td>
<td>#address#, #town#, #county#, #postCode#</td>
<td>#email#</td>
<td width="10%">#disp('#joinDate#')#</td>
</tr>

</CFOUTPUT>

</table>

<hr><p>End of members list.</p>

</body>
</html>


any ideas? please help me.
Apr 6 '07 #1
1 3927
acoder
16,027 Expert Mod 8TB
CreateODBCDate doesn't parse or validate entries. You should do that yourself, e.g. by using DateFormat to format the date into the correct format.
Apr 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Larry | last post by:
I have the following code attached to a search button on a form that runs a query. It works great, except that the search for Last Name only returns exact matches. It is even case sensitive....
0
by: teddysnips | last post by:
I have Search form that allows users to retrieve records into a DataGrid. There are two search criteria - a Month and a Year, which are selected from drop-down lists. There is a server-side...
0
by: teddysnips | last post by:
I have Search form that allows users to retrieve records into a DataGrid. There are two search criteria - a Month and a Year, which are selected from drop-down lists. There is a server-side...
5
by: Ron S | last post by:
After days of searching I finally an example that would work with my application, the only problem is after entering all of the code it is not working. Would someone be kind enough to take a look at...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
1
by: Froefel | last post by:
I'm trying to populate a gridview control based on a user's search criteria, but what seemed like a trivial task turns out to be a nighmare for this newbie... maybe someone can help. Here's the...
3
by: suek | last post by:
I have a table with over 4000 records to search upon, and the users don't like a combo box. So what I have been trying to do for the last twelve hours is do some code to get a text box to search. ...
3
by: CF FAN | last post by:
cf search using verity for my web site. I actually took the code from docs on teh web and tweeked a couple things out on it. Now it is throwing errors and I can't figure out why. What is funny is...
2
by: MNNovice | last post by:
I am working on a database on my CD collection using Access 2003. Some of the table structures are given below. Table 1 tblMusicCategory Field 1: MusicCategoryID - Auto Number (PK) Field 2:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.