另外,我知道怎么判断日期是不是今天了,可是写filter不知道怎么写
判断如下
:
    
    Dim a    As Date
    Dim b As Date
    
    a = CDate("2001-10-22 17:21:21")
    b = CDate("01-10-22 17:21:21")
    
    If Int(a) - Int(b) = 0 Then
        MsgBox ("is today")
    Else
        MsgBox ("not today")
    End If

解决方案 »

  1.   


    strSQL="Select * from Table Where convert(Datetime,time)='" & Format(Date,"YYYY-MM-DD") & "'"cn.Execute strSQL
      

  2.   

    Dim rs as AdoDB.RecordSet
    Dim strSQL as string
    strSQL="Select * from Table Where substring(time,1,8)='" & Format(Date,"YY-MM-DD") & "'"rs.Open strSQL  
    substring是SQL语句,用来取子串的,和VB的Mid函数类似.
     
      

  3.   

    能说明白点什么意思吗?
    select * from table where time like getdate()
      

  4.   

    我按照你们的方法,怎么说
    时实错误:'-2147***对象open的方法'_recordset' 失败rs.Open strSQL  

    cn.Execute strSQL 
    都是一样的错误
      

  5.   

    还有说convert函数没定义
    getdate()函数没定义
      

  6.   

    首先,既然这个字段是日期,设置字段为string 或者 var char,就都不利
    其次,现在的日期时间作为字符串来filter(就不用convert了)
    假设该字段名为 date
    nowtime=format$(date,"yy-mm-dd")
    strSQL="select * from table where time like '" & nowtime & "'"
    注意:这要用放置结果集recordset的方式,
         如果用database.Execute strSQL 则要指定库内放置表,要加 insert into的
         这多半是前面他们出错的原因。