Get records with Date()
December 4, 2002 by Dennis van Galen


How do I filter my recordset so that it returns only results for today ?


Set your filter so that it filters on Date()

You have to do this in the advanced recordset window, say we have a table holding events and these events have dates and we only want to display todays events. In simple mode we created this SQL statement:

then change that in advanced mode into:

FROM events
WHERE EntryDate = Date()

events being the tablename and EntryDate is the fieldname of our event date/time field.

Test it to confirm it only returns today's entries and that is all there is to it.

Now, if you want to display entries from the next 30 days alter it to something like this:

FROM events
WHERE EntryDate>=Date() AND EntryDate<Date()+30

Now let's say our client wants a page that shows a list with only the dates that have one or multiple events. We would simply change the query so that it reads:

Then on our "Master" page we would display these in a table and add repeat region to the row holding the dynamic dates that are returned to the page. We then apply a "goto detail page" behavior which we point to a page that lists all values for that specific date. On that page we would then apply another "goto detail page" behavior but we pass the "eventID" to show the details of the event the visitor wants to view, more on using the detail page behavior is found here:

Have fun playing with SQL commands !

Note: Date() as mentioned above is compatible with MS-Access, for SQL Server replace Date() with getDate()

Dennis van Galen

Dennis van GalenDennis started his career as order picker in warehouses. In the past 10 years he did alot of data-entry work for Government agencies and around the age of 20 he helped clean the KPN Telecom customer databases. At the age of 27 Dennis returned to KPN Telecom where he was a full time webmaster / webdeveloper. In his spare time he used to be a voluntary Manager for After leaving KPN in 2012 Dennis worked for on webbased customer satisfaction platforms.

In the past 12 years Dennis became experienced with various webtools, web-languages and database systems.

See All Postings From Dennis van Galen >>

Place your comment about Get records with Date()

You must me logged in to write a comment
How do I filter my recordset so that it returns only results for today ?
June 14, 2005 by Vicente Mollon Bustos
Hi, I just tried the solution you posted, and when tested it DW sends me a Error message that says: Undentifed error ocurred The SQL that I used is the same that you are posting: SELECT * FROM noticias WHERE fecha = Date() Can you tell me where is the problem and how I can Fix it? Thanks a lot