select * from ta where date bewteen '2006-12-29 00:00:00'and '2007-01-28 23:59:59'
where 日期〉=上月29日 and 日期<=本月28日??
where 日期字段>='2006-09-29' AND 日期字段<'2006-10-29' 字段是日期类型,建议用>=\<
select * from table where datefield>=cast(convert(char(8),dateadd(m,-1,getdate()),120)+'29' as datetime) and datefield<=cast(convert(char(8),getdate(),120)+'28' as datetime);
where datecolumn between '2002-10-29' and '2003-11-29' 大体意思是上面的,可能数据类型没有匹配好,搂主自己调整吧。
--tryselect * from tbName where colName>=dateadd(month, -1, convert(char(8), getdate(), 120)+'29') and colName<convert(char(8), getdate(), 120)+'29'
字段是日期类型,建议用>=\<
大体意思是上面的,可能数据类型没有匹配好,搂主自己调整吧。
where colName>=dateadd(month, -1, convert(char(8), getdate(), 120)+'29')
and colName<convert(char(8), getdate(), 120)+'29'