DANG i cant believe how much trouble such a simple thing is giving me. now i cant get a similar query to work.
the idea is that the first query is used to create a pull-down menu of dates in which entries were made into the database. once a date is selected, another query pulls all the data for that date... but anyway i try it it fails. if i avoid a syntax error i get an empty recordset returned. the last query i tried was
SELECT * FROM myTable
WHERE datevalue(tableDate) = 'datevalue(#Form.date#)'
thanks guys, but still no luck. without the quotes i get a "missing operator" error(!?)
also no luck with
DateValue([Forms]![name of open mainform]![name of date control])
which i dont even understand gives me a "Too few parameters" error. excuse me for having my head so deep up my ars, but i didnt even know there was a "!" operator in SQL? and why would you have to do a DateValue() on a value as you pull it from the DB when it is supposed to be stored as a date? isnt that for making a string into a Date datatype?
maybe i need to clarify im working in coldfusion, i didnt think that would matter for the sql part.
i really need to get my head around the fundamentals of dealing with dates i think. are there any good resources you would recommend?
note that this type of date condition (applying a function to the column) is inefficient because it requires a table scan, so if the table is large, you should have an index on the column, and then use this datetime range condition instead --
WHERE tableDate >= ###Form.date###
AND tableDate < ###DateAdd("d",1,Form.date)###
thanks, that did it! i would greatly appreciate a short explanation why that code blows up on me if i do it #var# but works with ###var###? in what circumstances are the extra # signs necesary?
as you know coldfusion uses # to delimit coldfusion expressions
but what if you want to generate a # into the output?
then you need to code two of them in a row
for example, in a style sheet,
background-color: ##F9F3F7
same for generating sql
now, as you know, access requires # to delimit dates, for example
#2006-12-04#
therefore, to generate an access date expression from a coldfusion variable, you first use ## to represent the opening access date delimiter, then #Form.date# for the actual value, then ## for the closing access date delimiter
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.