日期:2014-05-18  浏览次数:20445 次

求一句数据类型转换的SQL语句!
表内有2个字段
字段A varchar(50),记录的是开始时间, 格式yyyy-mm-dd
字段B varchar(50), 记录的是月份数

我想筛选出 开始时间 + 月份数 超过当前日期的所有记录,该怎么做啊

------解决方案--------------------
SQL code
select * from [Table] where dateadd(month,cast(b as int),a)>getdate()

------解决方案--------------------
SQL code
select * from [Table] where a>dateadd(month,-cast(b as int),getdate())
--or
select * from [Table] where datediff(ms,a,dateadd(month,-cast(b as int),getdate()))<0

------解决方案--------------------
SQL code

select * from [Table] where dateadd(mm,cast(字段B  as int),字段A )>getdate()