Posts tagged date filtering
Showing only present and future dates using SelectCommand in ASP.NET
Mar 11th
Where you have a database of events you can easily exclude those which have gone by leaving only current and future events. However, getting the SelectCommand syntax right is not obvious.
SelectCommand=”SELECT [EventName], [EventDate] FROM [EventsTable] WHERE DateValue([EventDate]) >= DATE() ORDER BY [EventDate]“
To show only current and future events add DateValue([EventDate]) >= DATE() to the WHERE clause of your data source SelectCommand. DateValue grabs the date value of your date field, DATE() returns today’s date.
This can be varied to show dates in the past by changing the operator from “>=” to “<” or past and present “<=”.
Works with ASP.NET 2.0 or higher.


