MS Access 2007:日期查询 [英] MS Access 2007: date query
问题描述
我需要有关MS Access 2007中日期查询的帮助.
I need help with date queries in MS Access 2007.
如何显示date:01/06/2010 time:10:51
和date:13/07/2010 time:22:30
之间的所有数据?
How do I show all data between date:01/06/2010 time:10:51
and date:13/07/2010 time:22:30
?
推荐答案
如果使用的是查询设计窗口,则比在VBA中工作时具有更大的自由度.在查询设计窗口中,您可以在标准行中以语言环境的格式输入日期和时间,在SQL视图中查看时,您可能会看到:
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#
但是,通常最好以年/月/日或年-月-日的格式输入日期,即使Access可能会将其更改为您的区域设置格式.在VBA中是一个不同的故事,Access需要月,日,年订单或年,月,日.年,月,日再一次更好.
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#
这篇关于MS Access 2007:日期查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!