I need help with date queries in MS Access 2007.
How do I show all data between date:01/06/2010 time:10:51
and date:13/07/2010 time:22:30
?
I need help with date queries in MS Access 2007.
How do I show all data between date:01/06/2010 time:10:51
and date:13/07/2010 time:22:30
?
I have not used MS Access for years, so this is only from memory: Access uses # instead of ' for date values. And you need to use ISO format:
WHERE datecolumn >= #2010-06-01 10:51# AND datecolumn <= #2010-07-13 22:30#
If you are using the query design window you have a lot more latitude than if you are working in VBA. In the query design window you can enter a date and time on the criteria line in the format for your locale, when viewed in SQL view, you might see:
SELECT tbl.CrDate
FROM tbl
WHERE tbl.CrDate Between #2/5/2006 14:7:0# And #11/18/2006 17:28:15#
However, it is generally best to enter dates in year/month/day or year-month-day format, even though Access may change it to your locale format. In VBA it is a different story, Access needs month,day,year order or year,month,day. Once again, year,month,day is better.
As regards your problem, if you have separated the date and time fields, it would be best to reunite them for the query, you can use + :
DateField + TimeField Between #01/06/2010 10:51# And #13/07/2010 22:30#