日期:2014-05-16  浏览次数:21045 次

月份之间查询
我想查询2007-4到2007-5份之间的数据。

数据库的格式是2007-4-4

数据库是ACCESS

------解决方案--------------------

select *
from 表名
where format(日期字段名, 'yyyy-mm ') between '2007-04 ' and '2007-05 '
------解决方案--------------------
select * from 表名
where year(日期字段名)=2007 and (month(日期字段名)=4 or month(日期字段名)=5)
------解决方案--------------------

如字段为日期型:
select *
from 表名
where format(日期字段名, 'yyyy-mm ') between '2007-04 ' and '2007-05 '
OR
select *
from 表名
where 日期字段名 between #2007-04# and #2007-05#

------解决方案--------------------
select *
from 表名
where format(日期字段名, 'yyyy-mm ') between '2007-04 ' and '2007-05 '