Skip to main content
Inspiring
September 26, 2013
Question

Baffled by date query

  • September 26, 2013
  • 1 reply
  • 747 views

It's been awhile since I've done any CF and I'm baffled by the results I'm getting. I want to select all the records where the date is greater than or equal to today. This is with CF8 and an Access database. There are records for 9/25 thru 9/30. I can't get the record for today to show.

<cfset dateToday = createODBCDate(Now()) />

<cfoutput>DateToday: #DateFormat(dateToday,'yyyy-mm-dd')#</cfoutput><br />

<br />

<cfquery datasource="survey" name="test">

          SELECT *

          FROM Images

          WHERE StartDate >= <cfqueryparam value="#DateToday#" cfsqltype="cf_sql_timestamp" />

</cfquery>

<cfoutput query="test">

#startdate#<br />

</cfoutput>

DateToday: 2013-09-26

Results:

  2013-09-27 00:00:00.0

  2013-09-29 00:00:00.0

  2013-09-28 00:00:00.0

  2013-09-30 00:00:00.0

Furthermore, if I eliminate the GT sign and have "StartDate =" today, there are no results.

This topic has been closed for replies.

1 reply

Inspiring
September 30, 2013

Now() includes a time component.  If you want records from earlier today, you have to create a date variable with no time element.   CreateDate, Year(), Month() and Day() will come in handy.