asp+access:生日查询
使用asp+access查询生日,一直没有通过。在此请教:
表Table
字段:id(会员id)、birthday(会员生日字段)
想实现以下效果。请教查询语句怎么写、
<table width="88%" border="0">
<tr>
<td width="47%" style="font-size:12px">生日查询:
<%if t=0 then%>今日生日会员<%else%>第<%=t%>天<%if stime=0 then%>之内<%end if%>生日会员<%end if%>:<span style="color:#FF0000; font-weight:bold"><%=xxx%></span> 位</td>
<td width="53%" align="right"><form style="margin:0; font-size:12px" id="form1" name="form1" method="post" action="sr.asp">
第
<select name="t" id="t">
<%
for i=0 to 10
%>
<option value="<%=i%>" <%if i=t then response.Write("selected")%>><%=i%></option>
<%
next
%>
</select>天
<input name="stime" type="radio" value="0" <%if stime<>1 then response.Write("checked")%>/>
之内
<input type="radio" name="stime" value="1" <%if stime=1 then response.Write("checked")%>/>
当天
<input type="submit" name="Submit" value="查找" />
</form>
</td>
</tr>
</table>
<%
Dim conn, rs, dbPath, sql
Set conn = Server.CreateObject("Adodb.Connection")
Set rs = Server.CreateObject("Adodb.RecordSet")
dbPath = "demo/Northwind.mdb"
sql = "SELECT * FROM 生日 WHERE Month(birthday) = Month(Now()) And Day(birthday) - Day(Now()) <= 7"
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(dbPath)
rs.Open sql, conn, 1, 3
Response.Write "7天内过生日名单:" & "<br>"
For i = 1 To rs.RecordCount
Response.Write rs("id") & " " & rs("birthday") & " 还剩天数:" & _
DateDiff("d", _
Date(), _
Year(Date()) & "-" & Month(rs("birthday")) & "-" & Day(rs("birthday"))) _
& "<br>"
rs.MoveNext
Next
%>
7天内过生日名单:
2 1982-05-23 还剩天数:1
4 1982-05-25 还剩天数:3
5 1982-05-25 还剩天数:3
6 1982-05-25 还剩天数:3
7 1982-05-26 还剩天数:4
8 1982-05-28 还剩天数:6