Skip to main content
Inspiring
January 9, 2007
Question

Query to find today's records?

  • January 9, 2007
  • 4 replies
  • 625 views
Hello,
I am working on a little CF project and I need to find all records that have today's date (time would also be included on the field, in case that is relevant) What query would you use to retrieve all records entered "today"? Thank you!
This topic has been closed for replies.

4 replies

Inspiring
January 10, 2007
How about:

WHERE myDateField BETWEEN '#DateFormat(now(), "m/d/yyy")#' AND '#DateFormat(now(), "mm/dd/yyyy")# 23:59:59'
GlennzigAuthor
Inspiring
January 10, 2007
n that case, you would use:

WHERE DateValue (YOUR_DATE_COLUMN) = DateValue (Now ())

Sorry, but it seems SQL is not recognizing DateValue as a valid command. it will yield a "data type mismatch" error.
January 10, 2007
No dateValue () has been part of Microsoft Access for a while now. What version of Access are you using?
Are you using Access as a front end to MS SQL?

Anyway, there is something else going on.

Turn on all debugging options and post the EXACT, FULL, error message here.

GlennzigAuthor
Inspiring
January 9, 2007
I am using Access, and the datatype is date/time
January 9, 2007
In that case, you would use:

WHERE DateValue (YOUR_DATE_COLUMN) = DateValue (Now ())
Inspiring
January 9, 2007
depends on the db you are using and the datatype of the field. In oracle for example,

where to_char(datefield, "mask") = to_char(sysdate, "same mask")

would work if datefield was a date field.