Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 selecting dates using CF operators

Author  Topic 

sydtek22
Starting Member

10 Posts

Posted - 2008-10-28 : 17:10:00
Okay I have spent five hours trying everything I can come up with and my head hurts.

I am using an Access DB and ColdFusion 7. I am trying to select a start date and end date for a report. The problem is when using the BETWEEN statement the start date and the end date are excluded from the query, so everything else is captured. I've tried using conversions, ODBCwrap, and GTE and LTE to retrieve the information. But nothing is returning the right information or any information at all. I think I have come close with this, but I can't find my syntax error.

Select * From Table WHERE
entrydate GTE #date1# AND entrydate LTE #date1#

Originally I was using cfqueryparam for the dates but I didnt get any information out of it as well. I'm just trying to get the start date and end date with everyhing in between. Any help or points in the right direction would be greatly appreciated!

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-28 : 17:24:24
try
<cfset STARTDATE= "2008-10-01">
<cfset ENDDate = "2008-10-31">
<CFQUERY>
SELECT * FROM TABL WHERE ENTRYDATE GTE #STARTDATE# AND ENTRYDATE LTE #ENDDATE#
</CFQUERY>
Go to Top of Page

sydtek22
Starting Member

10 Posts

Posted - 2008-10-28 : 18:10:24
I tried that but I only got this

Syntax error (missing operator) in query expression 'entrydate GTE 09/01/2008 AND entrydate LTE 10/27/2008'.

Maybe some parens are missing???

quote:
Originally posted by hanbingl

try
<cfset STARTDATE= "2008-10-01">
<cfset ENDDate = "2008-10-31">
<CFQUERY>
SELECT * FROM TABL WHERE ENTRYDATE GTE #STARTDATE# AND ENTRYDATE LTE #ENDDATE#
</CFQUERY>

Go to Top of Page
   

- Advertisement -