首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

asp+access:生日查询解决方案

2013-08-01 
asp+access:生日查询使用asp+access查询生日,一直没有通过。在此请教:表Table字段:id(会员id)、birthday(会

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>


[解决办法]
你查的是不是日期型?
------解决方案--------------------


1、取得当前日期checkdate
2、DateAdd往前取7天,checkdate_start
3、DateAdd往后取7天,checkdate_end
4、处于checkdate_start——checkdate_end之间

这样说还不明白的话,看看书去吧。
[解决办法]


<%
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


[解决办法]
说实话,asp+access这种技术,已经过时了。很少使用的
[解决办法]
asp+access这种技术,已经过时了 随然过时了,但比较简单,对不要复杂,但要做点小网页还是蛮实用的。
[解决办法]
http://bbs.csdn.net/topics/390472610

热点排行