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.
Here we will see, SQL Query to compare two dates. This can be easily done using equals to(=), less than(<), and greater than(>) operators. In SQL, the date value has DATE datatype which accepts date in 'yyyy-mm-dd' format. To compare two dates, we will declare two dates and compare them using the IF-ELSE statement.
Let's stop using DATEDIFF() or CAST() to filter a table on a DATETIME column. To filter a table on a DATETIME column comparing only the date part, use CAST() only around the parameter, and >= and < with the desired date and the day after.
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#;
try this..
SELECT * FROM BookingMaster where (JourneyDate >= #01/08/2012#) and (JourneyDate < #01/09/2012#);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With