d*******n 发帖数: 109 | 1 in SQL Server, is there a way if year(datetime) >= 2050 then returns ''
otherwise returns datetime
thanks | c*****a 发帖数: 177 | 2 ...
case
when v_datetime>='1-JAN-2050' then ''
else v_datetime end as v2_datetime
...
Not sure if this is what you need. | d*******n 发帖数: 109 | 3 这应该不是答案,事实上,后来我解决了问题。有了一个有意思的发现。
是这样的
如果我只是用
case when year(datetime) > = 2050 then ''
这样出来的结果是'1900-00-00...'
在datetime里面,0 or '' is 1900-00-...
后来我用了
case when cast(year(datetime),varchar) >= '2050' then ''
这样就work了。
【在 c*****a 的大作中提到】 : ... : case : when v_datetime>='1-JAN-2050' then '' : else v_datetime end as v2_datetime : ... : Not sure if this is what you need.
|
|