日期:2014-05-17  浏览次数:20470 次

如何判断字符的长度
select * from x_user where and datediff(day,getdate(),isnull(user_time,'3000-12-31'))>1
如何变成当user_time的长度小于5时,则是'3000-12-31'

------解决方案--------------------
SQL code
select * from x_user where and datediff(day,getdate(),(case when len(user_time)<5 then '3000-12-31' else user_time end)))>1

------解决方案--------------------
SQL code
SELECT CASE 
           WHEN LEN(user_time) < 5
           THEN '3000-12-31'
           ELSE ''
        END

------解决方案--------------------
SQL code
SELECT  *
FROM    x_user
WHERE   DATEDIFF(day, GETDATE(), CASE WHEN LEN(user_time) < 5 THEN '3000-12-31'
                                      ELSE ''
                                 END) > 1

------解决方案--------------------
SQL code
SELECT  CASE WHEN LEN(user_time) < 5 THEN '3000-12-31'
                                      ELSE ''
                                 END,*
FROM    x_user
WHERE   datediff(day,getdate(),isnull(user_time,'3000-12-31'))>1

------解决方案--------------------
SQL code
select (case when len(user_time)<5 then '3000-12-31' else user_time end) usertime from x_user where and datediff(day,getdate(),usertime))>1