使用 sql 查询的 vba 中的日期变量



我在VB6中有一个查询:

"select plate_no from INFO where date_time between #07-10-2012 01:13:17# and #10/10/2012 11:30:25#" 

我的 Access 数据库表包含数据类型为常规格式的"数据/时间"的列。

如何修改上面的查询以使用以下变量:

Public t1 As Date 
Public t2 As Date 

我是根据内存做的,可能需要调整它才能编译:

Public t1 as Date
Public t2 as Date
t1 = #10/07/2012 01:13:17# '7th of October 2012
t2 = #10/10/2012 11:30:25# '10th of October 2012
sql = "select plate_no from INFO where date_time between #" + Format(t1, "YYYY-MM-DD HH:MM:SS") + "# and #" + Format(t2, "YYYY-MM-DD HH:MM:SS") + "#"

最新更新