database 比较 Access SQL 查询中的日期

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11814853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 08:39:08  来源:igfitidea点击:

Comparing date in Access SQL query

databasems-accessms-access-2007

提问by roshanK

I'm having trouble with Access sql query. Im new to this so bieng a rookie its difficult to figure out the syntax. below is my query.

我在使用 Access sql 查询时遇到问题。我是新手,所以很难弄清楚语法。下面是我的查询。

SELECT *
FROM BookingMaster WHERE JourneyDate = #01/08/2012#;

below is the respective table data:

下面是各自的表数据:

BookingID   BookingDate    JourneyDate   CustomerName   TelephoneNo  Address
5            01-08-2012     01-08-2012         roshan         78889     hjgj    

the above query listed returns 0 results even though data exist for 01/08/2012 journey date.

即使存在 01/08/2012 旅程日期的数据,上面列出的查询也会返回 0 个结果。

Can anyone please help me out.

任何人都可以帮助我。

回答by Fionnuala

Unless you are working in a US locale, it is best to use a year, month, day format for dates:

除非您在美国地区工作,否则最好对日期使用年、月、日格式:

SELECT *
FROM BookingMaster where JourneyDate = #2012/08/01#;

回答by kakarott

try this..

尝试这个..

SELECT * FROM BookingMaster where (JourneyDate >= #01/08/2012#) and (JourneyDate < #01/09/2012#);