Back to Top
The nuts and bolts for
Creative web development

Get records with Date()

Question:


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

Answer:


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:

SELECT *
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:

SELECT *
FROM events
WHERE EntryDate>=Date() AND EntryDate<Date()+30
ORDER BY EntryDate ASC

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:
http://www.macromedia.com/support/dreamweaver/building_apps.html

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 DMXzone.com. After leaving KPN in 2012 Dennis worked for Tevreden.nl 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 >>

Share this Article

Comments

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

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