VBA查询插入时间而不是日期

时间:2014-07-23 10:46:07

标签: sql vba access-vba ms-access-2007

我需要一些帮助我的查询我试图插入一个表见上面的代码:

CurrentDb.Execute ("INSERT INTO tblWarehouseItem ( whiwrhID, whiItemName, whivatName," whiVatRate, whiimtID, whiQty, whiPrice, whisupID, whiDateIn, whiExpiryDate,whiwhiID ) " & _
                                   " Values (" & rs!WID & "," & Chr(34) & rs!N & Chr(34) & "," & Chr(34) & rs!VN & Chr(34) & "," & rs!VR & "," & rs!IID & "," & intQtyForm & "," & rs!PR & "," & rs!SID & "," & CDate(rs!DIN) & "," & CDate(rs!EXD) & "," & rs!ID & ")")

在我的表格中,CDate(rs!EXD)CDate(rs!DIN)会被存储为时间。

当我在即时窗口中编译我的查询时,我得到日期。

INSERT INTO tblWarehouseItem ( whiwrhID, whiItemName, whivatName, whiVatRate, whiimtID, whiQty, whiPrice, whisupID, whiDateIn, whiExpiryDate,whiwhiID )  Values (2,"ITEM10","A",19,14,4,20,10,21/07/14,26/05/14,60)

如何让我的查询在表格中插入日期?

提前致谢

1 个答案:

答案 0 :(得分:2)

如果你运行21/07/14传递给Access并解释为12 divide by 7 divide by 14产生的整数,当转换为日期时只是一个时间。

使用#

分隔日期
.. ",#" & CDate(rs!DIN) & "#," ..