I would like to compare dates in MS ACCESS SELECT * FROM Ledger WHERE TranDate>1/1/2008 TranDate<1/1/2009 ORDER BY TranDate; But when I use the above it gives no results where as there are lots of records for 2008 and when I use quotes it gives error saying datatype mismatch
I think this should work : Code: SELECT * FROM Ledger WHERE TranDate BETWEEN #1/1/2008# AND #1/1/2009# ORDER BY TranDate; I think you have used Oracle or SQLServer earlier, so you used quotes. But the delimiter in MS Access is # not '
U Haven't used "and" keyword to join both conditions..use it like this.. SELECT * FROM Ledger WHERE TranDate>1/1/2008 andTranDate<1/1/2009 ORDER BY TranDate; And Also be Sure that TranDate is Text dataType ......
U Haven't used "and" keyword to join both conditions..use it like this.. SELECT * FROM Ledger WHERE TranDate>#1/1/2008# andTranDate<#1/1/2009# ORDER BY TranDate; # delimitter must used in ms access
That won't work without # delimiter. TranDate is obviously Date data-type. Sriram, don't be hurried to post. Take your time and include all you want to say in one post.
Of course it is date datatype if we don't use # then trandate should be text datatype else if it is date datatype then we have to use #....Cool KID.