表(1)
id dept buyer create_date
5302 亿龙恒嘉珠宝公司 管理员 '2009-6-4'
5305 亿龙恒嘉珠宝公司 管理员 '2009-6-11'
5306 亿龙恒嘉珠宝公司 管理员 '2009-7-14'
5303 亿龙恒嘉珠宝公司 管理员 '2009-7-16'
5307 亿龙恒嘉珠宝公司 管理员 '2009-8-2'
5304 亿龙恒嘉珠宝公司 管理员 '2009-8-7'请问怎么查询今天7号到上个月7号的的数据啊 。。.
id dept buyer create_date
5302 亿龙恒嘉珠宝公司 管理员 '2009-6-4'
5305 亿龙恒嘉珠宝公司 管理员 '2009-6-11'
5306 亿龙恒嘉珠宝公司 管理员 '2009-7-14'
5303 亿龙恒嘉珠宝公司 管理员 '2009-7-16'
5307 亿龙恒嘉珠宝公司 管理员 '2009-8-2'
5304 亿龙恒嘉珠宝公司 管理员 '2009-8-7'请问怎么查询今天7号到上个月7号的的数据啊 。。.
from tb
where DATEDIFF(month,create_date,GETDATE())=1
select * from tb
where create_date between dateadd(mm,-1,getdate()) and getdate()
where create_date between dateadd(mm,1,create_date ) and getdate()
from tb
where datediff(day,create_date, DATEadd(month,-1,GETDATE()))<0
select *
from tb
where DATEDadd(month,create_date,GETDATE())=-1
顶楼上。,
select * from Tb where create_table betwen '2009-07-07' and gatedate()