Access (ADO) query between two hour ranges

有些话、适合烂在心里 提交于 2019-12-11 08:47:39

问题


Using VB to query an access .mdb database via ADODB.

My date column holds both date and time, I would like to to build a query which will ignore the date, and refer only to the time in that column, in such a way, that will enable me to return records that have their time in between a range given by the user, ignoring the date.

I tried selecting between numbers, but I believe access I'm doing it wrong

...WHERE [Date_Time_Of_Birth] Between #04:00:00# and #06:00:00#

Just doesn't work as intended ... need a direction here.


回答1:


Use the TimeValue Function to ignore the date portion of your Date_Time_Of_Birth values.

Also #04:00:00# and #06:00:00# are 4 and 6 AM. Since you want PM times, write the values as in one of these examples:

WHERE TimeValue([Date_Time_Of_Birth]) Between #16:00:00# and #18:00:00#

WHERE TimeValue([Date_Time_Of_Birth]) Between #4 PM# and #6 PM#


来源:https://stackoverflow.com/questions/29568843/access-ado-query-between-two-hour-ranges

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!