Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i write a coldfusion query using a where data/time field = date

Status
Not open for further replies.

xor

Programmer
Jan 7, 2001
71
NZ
I am trying to write a coldfusion query to extract info from an MS Access97 database, something like:

<cfset today=DateFormat(Now())>

<cfquery=&quot;get_todays_records&quot; ...>
SELECT *
FROM MyTable
WHERE date = '#today#'>

I have the format of the field 'date' set to medium date, so if I look at the records it looks like this: 07-Dec-00.
I have tried using today=CreateODBCDate(Now()) and that doesn't work either. Any ideas?
 
ahha!
SELECT *
FROM visitor_stats
WHERE date = #CreateODBCDate(Now())#

does the trick, notice no '' that is what makes the difference.
 
I recommend using the full date in Acces, since you might be needing more date-info in the future, you can format the date with ColdFusion, it is more standardized et cetera.
Use the standard date format in Access together with #CreateODBCDateTime(Now())# and I think it will work. Please let me know if it doesn't. <webguru>iqof188</webguru>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top