Seek help for select Month in list box
Hi,
I need help to select Month and Year in my list box. My database column data type is date/time. My problem is i not sure the way to display "Date" data from database table name "db1" list box value Month and Year in my interface. My purpose is to display recordset in my date data accoding Month and Year select by user. Please help me.
Below is my example code:
<%
MM=Request.Form("MM")
yyyy=Request.Form("yyyy")
mon = Month(date())
If len(MM)=0 then MM=mon
Yr = Year(date())
MinYr = Yr - 2
MaxYr = Yr + 2
If len(yyyy)=0 then yyyy=Yr
%>
<Form name="frm" method="Post" action="">
<p align="center">Month : <Select name="MM">
<%
For i = 1 to 12
%>
<Option Value="<%=i%>" <%If cint(i) = cint(MM) then%> Selected <%End If%>><%=MonthName(i)%></option>
<%
Next
%>
</Select>
Year : <Select name="yyyy">
<%
For i = MinYr to MaxYr
%>
<Option Value="<%=i%>" <%If cint(i) = cint(yyyy) then%> Selected <%End If%>><%=i%></option>
<%
Next
%>
</Select>
<input type="Submit" value="Submit"> </p>
</Form>
<%
MM=Request.Form("MM")
yyyy=Request.Form("yyyy")
if MM<>"" then
accessdb="Green"
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("guessbooks.mdb"))
set rsMonth = Server.CreateObject("ADODB.recordset")
sql = "SELECT * FROM db1 WHERE Date = " & MM & " and Date= " & yyyy
rs.Open sql, conn
%>
There is an error : Error Type:
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'
apple
__________________
apple
|