Comparing date in Access SQL query

roshanK picture roshanK · Aug 5, 2012 · Viewed 42.3k times · Source

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.

Answer

Fionnuala picture Fionnuala · Aug 5, 2012

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