rs.Filter="字段名>='2001-08-07' and 字段名<'2001-08-07'"

解决方案 »

  1.   

    select * from A  where datediff(d,时间字段名,'2001-08-07')=0
      

  2.   

    谢谢ganzhiruogy,不过
    问题看上去简单,但我希望各位大侠至少在SQL查询分析器调试通过再回复
    我会一直关注,我调试通过马上加分,不够再加
      

  3.   

    rs.Filter="字段名>='2001-08-07' and 字段名<'2001-08-08'"
      

  4.   

    谢谢clarain,在SQL查询分析器调试通过,
    但在ADO的Filter中出错,请再帮我想想办法
    ?swhere
    datediff(d,fdtmdate,'2001-08-07')=0
    ?rsgrid("fdtmoptime")
    2001-8-4 18:19:32 
    ?err.Description 
    变量或者类型不正确,或者不在可以接受的范围之内,要不就是与其他数据冲突。
    ?err.Number 
     3001 
      

  5.   

    问题太难还是没激情???
    还有31分在http://www.csdn.net/expert/topic/231/231056.shtm
      

  6.   

    '以 SQL 2K 的 Northwind 为例
    Dim adoConnection As New ADODB.Connection
    Dim adoRecordset As New ADODB.Recordset
    adoConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Northwind;Data Source=server\psql2ke"
    adoRecordset.Open "select * from [Orders]", adoConnection, adOpenKeyset
    Debug.Print adoRecordset.RecordCount
    adoRecordset.Filter = "OrderDate='1996-07-04'"
    If Not adoRecordset.EOF Then
       Debug.Print adoRecordset.GetString
    End If
    Debug.Print adoRecordset.RecordCount
      

  7.   

    谢谢playyuer(女㊣爱),不过你的例中的“orderdate”字段的值都是只有日期没有时间
      

  8.   

    我记得RS的Filter可以使用VBA函数(FORMAT),这样应该就可以了(没有试过)
      

  9.   

    Dim Sql As String
    Dim Conn As New ADODB.Connection, Rs As New ADODB.Recordset
    Sql = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Northwind;Data Source=server\psql2ke"
    Conn.Open (Sql)
    Sql = "select * from T_init where datediff(d,fsrq,'2001-5-11')=0"
    Set Rs = Conn.Execute(Sql)
    While Not Rs.EOF
    Debug.Print Rs(0) 
    Rs.MoveNext
    Wend
    上面的程序在VB中调试通过!!!
    这样运行不是可以吗,为什么要非要用Filter那??
      

  10.   

    他肯定使用了n-tier,必须在客户端进行数据过滤,这种情况我也遇到过。只不过我是重新发送SQL语句来做的。
      

  11.   

    Hello!
    如果非要用Filter那么就这么解决:
    把你的Rs.Filter = "日期字段 = #2001-05-11#"
    你的程序修改如下:
    Dim Sql As String
    Dim Conn As New ADODB.Connection, Rs As New ADODB.Recordset, Rst As New ADODB.Recordset
    Sql = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Northwind;Data Source=server\psql2ke"
    Conn.Open (Sql)
    Sql = "select * from A"
    Set Rs = Conn.Execute(Sql)
    Rs.Filter = "fsrq = #2001-05-11#"
    Set Rst = Rs
    While Not Rst.EOF
    Debug.Print Rst(0) 
    Rst.MoveNext
    Wend
    ....................
    此程序在VB中调试通过
    主要是在Filter中时间的表示是用两个#Date#表示的!
      

  12.   

    谢谢clarain ,不过你的例中northwind的字段的值都是只有日期没有时间的,是吗
    辛苦了 10分,这个问题我已经解决,但新的问题来了,还有50分
    大家可以自由发挥,我只要结果把表1:
     字段A               字段B  字段C
    2001-08-01      233 111.00
    2001-08-05      132         222.12和表2:
    字段D 字段E
    2001-08-03    123
    2001-08-05    545查询出如下型式:
     字段A               字段B  字段C 字段E
    2001-08-01      233 111.00 NULL
    2001-08-03          NULL NULL 123
    2001-08-05      132         222.12 545