我是在SQL语句里
比如select *,CONVERT(varchar(10),datediff(d,tp_created,getdate()))+'.jpg' as img from table要判断CONVERT(varchar(10),datediff(d,tp_created,getdate())) 这个大于5什么在SQL里判断,我想在SQL语句里定义,直接在gridview里显示,要什么用

解决方案 »

  1.   

    用case when
    你要判断是那个日差的吧..
    select *,CONVERT(varchar(10),*,(case when datediff(d,tp_created,getdate())>5 then ... else .... end))+'.jpg' as img from table
      

  2.   

    放到where字句中判断可以吗?
      

  3.   

    select *,CAST(case when datediff(d,tp_created,getdate())>5 then ... else .... end AS VARCHAR(10))+'.jpg' as img from table
    或者直接让时间相减再判断应该也行