帮帮看看这个查询语句怎么写?
我的表有个字段“收费月份" 里面记录的是:2004年1月,2004年2月,2004年3月....
怎样查询介于2004年3月到2004年8月的数据?
问题点数:0、回复次数:4Top
1 楼lin_now(林)回复于 2005-01-03 20:48:18 得分 0
between .........and........Top
2 楼bitzhw(烦人)回复于 2005-01-03 21:52:30 得分 0
select * from 收费资料表 where 收费月份 between '2004年3月' and '2004年8月'
这样不行,'2004年3月' 怎样转化为日期类型才可比较呀Top
3 楼SARSII(八声)回复于 2005-01-03 23:36:28 得分 0
select * from 收费资料表 where 收费月份 between cast(left('2004年3月',4)+'-'+substring('2004年3月' ,6,(case when len('2004年3月')=7 then 1 else 2 end))+'-1' as datetime)and cast(left('2004年8月',4)+'-'+substring('2004年8月' ,6,(case when len('2004年8月')=7 then 1 else 2 end))+'-1' as datetime)
有点哆嗦,其实可做个转换函数。Top
4 楼tonny_yang(彩虹边的雨云)回复于 2005-01-04 09:49:54 得分 0
select * from 收费资料表 where DATEDIFF(DAY,'03/01/2004',收费月份) >= 0 AND DATEDIFF(DAY,'08/31/2004',收费月份) <= 0Top




