日期有时间时,访问查询将不起作用 [英] Access query won't work when dates have times

查看:53
本文介绍了日期有时间时,访问查询将不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询陈述:

select *
from tblClient
where IntakeDate = #5/31/2011#

事实上,我知道有8条记录带有该日期.但是此查询不会提取该日期的记录.这8条记录具有时间和短日期"(例如"2011年5月31日下午1:42:00")

I know for a fact there are 8 records that have that date. But none of records with that date are pulled by this query. Those 8 records have times as well as "short date" (e.g. "5/31/2011 1:42:00 PM")

作为测试,我将一条记录的日期设置为2011年5月31日,查询将适用于该记录.显然,时间值干扰了此查询.

As a test I set the date to exactly 5/31/2011 for one record, and the query will work for that one record. Clearly the time value is interfering with this query.

我不想将所有日期数据更改为严格的短日期"格式,而是希望按原样使用它.谁能给我一些想法,让我如何做这项工作?

I do not want to change all the date data to a strict 'short date' format and would like to work with it as-is. Can anyone give me some idea how I can make this work?

推荐答案

创建一个包含一天时间范围的条件:

Create a condition that encompasses a single day's time range:

select *
from tblClient
where IntakeDate >= #5/31/2011# AND < #6/1/2011#

[您可以使用 DateValue() 列上的函数,但这将阻止使用任何索引.]

[You could use the DateValue() function on your column, but that would prevent any index being used.]

这篇关于日期有时间时,访问查询将不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆