我写了一个vbscript来连接excel文件(.xlsx)作为使用ADODB连接的数据库。我想从excel文件中提取记录,其中"StartDate"列的值大于"15/05/2015",但在执行adodb查询时,错误被抛出为"标准表达式中的数据类型不匹配"。
我试图将'StartDate'列转换为使用' convert '和'Cast'函数的日期格式,但不支持。如何编写查询来检索记录?
excel中'StartDate'列的值看起来像"21/05/2015 0:00"双击该字段看起来像"21/05/2015 12:00:00 AM"
我尝试过的查询(所有查询都会抛出数据不匹配错误):
Select * from [Student$] where StartDate >= '15/05/2015'
Select * from [Student$] where StartDate >= '15/05/2015 12:00:00 AM'
Select * from [Student$] where StartDate >= '15/05/2015 00:00:00.000'
Select * from [Student$] where StartDate >= '15/05/2015 0:00'
日期文字的标记是#
,所以使用
Select * from [Student$] where StartDate >= #15/5/2015#
cf。