表 table1
字段 time
字段 idtime字段id为54 有三个时间(2011-1-15 21:10:59)(2011-1-18 0:20:18)(2011-1-30 0:20:18)查询table1中的字段time,条件id=54,相隔的最大天数
以下代码得出三个时间,我要最大的天数,帮我改一下select datediff(day,time,getdate()) from table1 where id='54'
字段 time
字段 idtime字段id为54 有三个时间(2011-1-15 21:10:59)(2011-1-18 0:20:18)(2011-1-30 0:20:18)查询table1中的字段time,条件id=54,相隔的最大天数
以下代码得出三个时间,我要最大的天数,帮我改一下select datediff(day,time,getdate()) from table1 where id='54'
select top 1 datediff(day,time,getdate()) from table1 where id='54' order by datediff(day,time,getdate()) desc
from table1 where id='54' order by 1 desc
select top 1 datediff(day,time,getdate()) as aaa
from table1 where id='54' order by 1 desc
select DATEDIFF(day, min([TIME]),getdate()) From [TABLE1] where ID=54
select DATEDIFF(day, min([TIME]),getdate()) From [TABLE1] where ID=54
同志,你说 -17 和 +1 不加绝对值 top 选出来的是不是 + 1
但正确要的 结果应该是 -17 的那个,也就是相差 17 天