954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Select statement with date not working with ms access database

Hey guys

I was hoping you help, I have a ms access database on my webserver. I want to select all the records with a certain date. But it seems not to work.

<CFQUERY NAME="qStuff" DATASOURCE="MyDb" maxrows="20">
SELECT *  FROM Stuff;
WHERE (((Stuff.RegDate)=#5/1/2004#));
</CFQUERY>


When I do this in MSAccess sql view it works but doesn't work on cfm page. Please help:'( I have also tried shifting the date formats.

tapuwa2002
Newbie Poster
22 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
 

Why do you have semicolons? Have you tried removing them because I think that ends a sql query?

cfwebdeveloper
Junior Poster in Training
78 posts since May 2011
Reputation Points: 19
Solved Threads: 8
 

Yes I have removed them, but now it returns this decimal data type

(Stuff.RegDate)=11.4261363636)
tapuwa2002
Newbie Poster
22 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
 

I should of saw this from the beginning but you need three pound signs around your date ###5/1/2004###. See if that works.

cfwebdeveloper
Junior Poster in Training
78 posts since May 2011
Reputation Points: 19
Solved Threads: 8
 
When I do this in MSAccess sql view it works but doesn't work on cfm page.

(Yeah, that's special "Access" syntax. It may work with some drivers, or it may not.) But the correct way to pass dates in cfquery is with cfqueryparam.

WHERE Stuff.RegDate = <cfqueryparam value="5/1/2004" cfsqltype="cf_sql_timestamp">
Please help I have also tried shifting the date formats.


That only changes the user display. It doesn't make any difference to your query.

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

Thanks

tapuwa2002
Newbie Poster
22 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You