不明白select * from table where time_field = '00:00:10'
请把时间日期的东西也当成 字符串来处理,我就是这么做的。 "00:00:10" > "00:00:09" is True唯一要求的是 比较格式要完全一样,要format一下,"2001-1-1" 和 "2001-01-02"比较得的结果就可能不正确了。
Dim qry As QueryDef Dim time1 As Date Dim strSQL As StringOn Error GoTo errSelectDocSet qry = qdfDoc time1 = CDate("00:00:01")Debug.Print Str(lTime) + "s =" + Str(time1)strSQL = "select * from 资料 where 时间='" + Trim(Str(time1)) + "'"With qry .SQL = strSQL .Execute '这里出错 If .ReturnsRecords Then Debug.Print .Fields("EID") End If End With
strSQL = "select * from 资料 where 时间='" + time1+ "'"
楼上,time1是Date型,不是子符串,无法相加。
strSQL = "select * from 资料 where 时间=#" + time1+ "#"即可 错误是其他地方引起的。
Dim time1 As Date
Dim strSQL As StringOn Error GoTo errSelectDocSet qry = qdfDoc time1 = CDate("00:00:01")Debug.Print Str(lTime) + "s =" + Str(time1)strSQL = "select * from 资料 where 时间='" + Trim(Str(time1)) + "'"With qry
.SQL = strSQL
.Execute '这里出错
If .ReturnsRecords Then
Debug.Print .Fields("EID")
End If
End With
strSQL = "select * from 资料 where 时间='" + time1+ "'"
错误是其他地方引起的。