MS Access日期转换错误

时间:2014-07-29 10:01:23

标签: vb.net ms-access ms-access-2007 date-formatting

我的MS Access sql字符串是:

select billdate from sales where billdate=#27/07/2014#;

此字符串显示结果为:27/07/2014。

但是,如果我输入

select billdate from sales where billdate=#01/08/2014#;

字符串不显示任何结果。 但如果我用#01/08/2014#替换billdate #08/01/2014# 该字符串显示结果为:01/08/2014。

在sales表中,billdate列的日期格式为Short Date。 我的系统日期和时间设置为dd/mm/yyyy格式。

我实际上在使用VB.NET。但问题仍然存在于Access而不是我的VB代码。我正在使用MonthCalendar对象。

如果可能,请在数据库级别提供解决方案。如果不可能,那么只给我编码级别的代码。

1 个答案:

答案 0 :(得分:0)

尝试在VB.net中格式化您的值。

你的字符串应该像这样构建:

Dim SQL as string = "select billdate from sales where billdate=" & Format(YourDate, "#yyyy\/MM\/dd#")

相关问题