当前位置: 代码迷 >> Sql Server >> 求一句数据类型转换的SQL语句!该怎么处理
  详细解决方案

求一句数据类型转换的SQL语句!该怎么处理

热度:24   发布时间:2016-04-27 18:45:36.0
求一句数据类型转换的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())--orselect * 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()
  相关解决方案