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

高分求购SQL语句(ASP+access)!
table   中有字段count(整数),time(日期/时间),days(整数)
要求:
        如果当前时间减去time中的时间   >   days中的天数,
则更新这条记录的count为count+1,请写出完整的update语句。

------解决方案--------------------
试试这句:

update 表名 set count=count+1 where DateDiff( "d ",time,Date()) > days
------解决方案--------------------
update 表名 set count=count+1 where DateDiff( "d ",time,now()) > days

------解决方案--------------------
update 表名 set [count]=[count]+1 where DateDiff( "d ",[time],now()) > days


------解决方案--------------------
楼上的几位写法可行,不过效率高点可以这样写

declare @ValidTime datetime
set @ValidTime=dateadd(day,-days, getdate())
update 表名 set count=count+1 where [time] <@ValidTime
------解决方案--------------------
update 表名 set count=count+1 where DateDiff( "d ",time,now()) > days
------解决方案--------------------
晕~自己换算一下都不行呀~
update 表名 set [count]=[count]+1 where DateDiff( "s ",[time],now()) > (days * 86400)
------解决方案--------------------
update 表名 set [count]=[count]+1 where DateDiff( "d ",[time],now()) > days
应该就可以了!~
------解决方案--------------------
update 表名 set [count]=[count]+1 where DateDiff( "s ",[time],now()) > (days * 86400)
就这样写就可以了