为什么我的sql语句两个日期相减,结果是null那,看了好久也没理出头绪,望各位大侠指点下![code=SQL][/code]
select a.billno,b.batchno,a.transdt,b.qty,b.mony,datediff(day,a.transdt,convert(varchar(24),@uQuerytime,121)) as kl
from ec_billhead a
left join ec_billbody b on a.transid=b.transid
where [email protected] and a.transdt<@uQuerytime and a.transqual<>-1 and isnull(b.actiflg,0)<>3 order by a.transdt desc
------解决方案--------------------
注意下参数及在做计算中的字段值有没有为NULL的存在,[email protected],那么datediff也为NULL,如果a.transdt值有NULL,那么对应的datediff也为NULL。
------解决方案--------------------
你把这两个日期单独都select出来就清楚了
------解决方案--------------------
你执行下 select a.transdt from ...看看 [email protected]