Problem with CreateODBCDate Function

I am using CF8 and an Access 2000 database that contains the following fields:

 - ID (autonumber)
 - EventDate2 (date/time)
 - EventTime (text)
 - School (text)
 - Event (memo)
 - Description (memo)

My form page contains 3 form fields, the School (drop down), the start date (text) and the end date (text).
Whenever I try to query my database by school AND between the 2 date ranges, I get no results, and yet there are plenty of dates in the database that meet the search requirements. Here is my SQL statement.

<cfquery name="q_Cal" datasource="#DataSource#">
  Select *
  FROM TBL_Cal
  WHERE Location = '#SchoolDrop#' AND EventDate2 BETWEEN #startdate# and #enddate#
</cfquery>

From some reading I have done, it appears that I need to convert my dates to ODBC compatible dates using the CreateODBCDate function. But this function takes 3 parameters (year, month, day) and my date fields are in short date formats, e.g. 01/01/2008. How can I convert my dates to ODBC format using only the short date format?

Ken
kenjpeteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PluckaCommented:
Well if your date lives in dateVar ie

dateVar = "31/12/2008" (ie DD MM YYYY)

You can just pull apart the string

createODBCDate(right(dateVar, 4), mid(dateVar, 4, 2), left(dateVar, 2))
0
black0psCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kenjpeteAuthor Commented:
I'm not sure how that would look in my SQL statement? Can you be more specific?
0
kenjpeteAuthor Commented:
Thank you....that was my mistake, I was looking CreateODBCDate but using CreateDate, which does require 3 parameters.
0
black0psCommented:
<cfquery name="q_Cal" datasource="#DataSource#">
  Select *
  FROM TBL_Cal
  WHERE Location = '#SchoolDrop#' AND EventDate2 BETWEEN #CreateODBCDate(startdate)# and #CreateODBCDate(enddate)#
</cfquery>

I use MS SQL. I made the switch some time ago so its been a while since I've used access scripting. You might need to encapsulate the dates with single quotes. Give each one a try. You might also consider trying the following:  

<cfquery name="q_Cal" datasource="#DataSource#">
  Select *
  FROM TBL_Cal
  WHERE Location = '#SchoolDrop#' AND EventDate2 > #CreateODBCDate(startdate)# and EventDate2 < #CreateODBCDate(enddate)#
</cfquery>
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.