> I'm trying to write a query to find records matching today's date. What
> I have is:
>
> <CFSET timestamp = #DateFormat(now(),"yyyy-mm-dd")#>
>
> <!--- find based on date --->
> <CFQUERY DATASOURCE="#SESSION.dsn#" NAME="gm_drawings_bydate">
> SELECT
> *
>
> FROM
> uprr_drawings dwg
>
> WHERE
> dwg.mod_date = #timestamp#
> </CFQUERY>
>
> From the table, the data looks like this:
>
> 1/5/2001 22:42:09,
> 11/13/2000 07:47:16
> and so on ...
I know this is going to sound odd, but SQL matches date AND time together -
if you want all entries in a day, then you're probably going to have to use
BETWEEN or a more complicated WHERE
Try;
<cfset timestamp=CreateODBCDate(Now())>
<cfquery datasource="" name="">
select *
from dwg
where dwg.mod_date between #timestamp# and #DateAdd("d",1,timestamp)#
</cfquery>
This SHOULD give you the results, but it may give you midnight of the
following day - if it does, change the DateAdd to;
DateAdd("s",-1,DateAdd("d",1,timestamp))
HTH
Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133
"Websites for the real world"
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists