Comparing date in Access SQL query

一笑奈何 提交于 2019-12-04 19:48:55

问题


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.

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.

Can anyone please help me out.


回答1:


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#;



回答2:


try this..

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


来源:https://stackoverflow.com/questions/11814853/comparing-date-in-access-sql-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!