如何取得8月1号到11月30号之间的时间?
现在的时间是2004年12月3号,如何取得不包括当前月的前4个月的记录?(也就是8月1号到11月30号) 问题点数:100、回复次数:7Top
1 楼skyboy0720(曲终人散)回复于 2004-12-03 12:51:53 得分 0
select * from 表 where 时间字段<dateadd(month,-4,getdate())Top
2 楼Leftie(左手,为人民币服务)回复于 2004-12-03 12:52:33 得分 0
select * from tablename where month(日期字段) between month(getdate())-4 and month(getdate())-1Top
3 楼skyboy0720(曲终人散)回复于 2004-12-03 12:52:49 得分 0
sorry:
select * from 表 where 时间字段 between dateadd(month,-4,getdate()) and dateadd(month,-1,getdate())
Top
4 楼yelook(香槟酒)回复于 2004-12-03 12:53:03 得分 100
select * from tablename where time>=dateadd(month,-4,convert(char(8),getdate(),120)+'01')
and time<convert(char(8),getdate(),120)+'01'Top
5 楼tddw(承接各种项目)回复于 2004-12-03 12:53:27 得分 0
select * from aa where ddate < convert(varchar(4),year(date())) + '-' + convert(varchar(4),month(date())) + '-1') and ddate > convert(varchar(4),year(date())) + "-" + convert(varchar(4),month(date())-4) + '-1')Top
6 楼yelook(香槟酒)回复于 2004-12-03 12:53:35 得分 0
我的是对的Top
7 楼tddw(承接各种项目)回复于 2004-12-03 12:54:44 得分 0
我的ddate > ....改成ddate >=Top




