Help with SQL - filter for "today"
I am new to asp and sql statements and would appreciate some advice.
I have successfully created a page which displays fields from a database to generate a list of events dates, times, event details and so forth.
What I want to add now is a filter in the SQL statement to display only those records in a given date range. I think I know how to do that, but the complication comes whereby I want the start of range to be "today" and the end of range to be "today" + 30 days.
Here is what I have coded so far as the sql statement and the variable"today" is concerned.
In Code behind file...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim today As Date = Date.Now()
End Sub
In SQL query on page displaying results from database(using gridview control)...
SelectCommand="SELECT * FROM [tblDiary] ORDER BY [Short_Date], [Start_Time]"
Essentially how do I pass the value of "today" in my example to a parameter in a "Where" clause of the SQL statement?
Any advice would be greatly appreciated.
Kind Regards.
|