Access sql query between date range with local date notation

时间:2018-11-13 14:20:12

标签: sql ms-access

I tried to open a RecordSet in Access with the following query but I get a syntax error every time.

SELECT  FromDate
        , UntilDate
        , NotificationText
        ,NotificationDetail 
FROM    ChangeNotification 
WHERE   FromDate <= #" & Date & "# AND 
        UntilDate >=#" & Date & "#"   

The Date notation is in 22.11.2018 because apparently it's localized and I didn't find a way to undo it.

Do you know a way to execute the query anyway?

Thanks alot

1 个答案:

答案 0 :(得分:1)

如果Date是相同的VBA过程,则可以使用以下方法:

SELECT FromDate, UntilDate, NotificationText, NotificationDetail FROM ChangeNotification WHERE FromDate <= Date() AND UntilDate >= Date()

我还假定表中的字段FromDateUntilDate的数据类型为Date/Time