另外,我知道怎么判断日期是不是今天了,可是写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
判断如下
:
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
strSQL="Select * from Table Where convert(Datetime,time)='" & Format(Date,"YYYY-MM-DD") & "'"cn.Execute strSQL
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函数类似.
select * from table where time like getdate()
时实错误:'-2147***对象open的方法'_recordset' 失败rs.Open strSQL
或
cn.Execute strSQL
都是一样的错误
getdate()函数没定义
其次,现在的日期时间作为字符串来filter(就不用convert了)
假设该字段名为 date
nowtime=format$(date,"yy-mm-dd")
strSQL="select * from table where time like '" & nowtime & "'"
注意:这要用放置结果集recordset的方式,
如果用database.Execute strSQL 则要指定库内放置表,要加 insert into的
这多半是前面他们出错的原因。