2015-06-10 100 views
0

我已经写了一个vbscript来连接excel文件(.xlsx)作为使用ADODB连接的数据库。我想从excel文件中提取'StartDate'列中的值大于'15/05/2015'的记录,但是在执行adodb查询时,将引发错误为“标准表达式中的数据类型不匹配”。将列转换为日期时间格式时不支持转换和转换功能(在VBScript - Excel adodb中)

我试图使用'Convert'和'Cast'函数将'StartDate'列转换为日期格式,但不支持。如何编写查询来检索记录?

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' 

回答

1

date literals的标记#,所以使用

Select * from [Student$] where StartDate >= #15/5/2015# 

cf. here

+0

非常感谢好友,它的工作:) –