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

怎样将日期的差值变成逻辑型字段?
比如这样一个表   tt
pid,pname,date1
1       张三     2007-5-8

我想新生成一个字段,其值为date1是否大于现在日期
select   *,(date1> getdate())   as   vv   from   tt

结果出错,不知道有什么变通的办法吗?


------解决方案--------------------
select *,
cast(case when datediff(day,date1,getdate()) > 0 then 1 else 0 end as bit) as vv
from tt
------解决方案--------------------
select *, vv=case when date1> getdate() then 1 else 0 end from tt