一个日期函数的问题

SQL SERVER2000

表里有两个字段

shdate(datetime)收货日期, maxdate(int,4),限制天数
2002-02-03 4

我想查询日期超过限制天数的记录该怎样写。
那得到结果应该是
如果到了2002-02-07,就提示
---------------------------------------------------------------

select * from table where shdate+maxdate<=getdate()

select * from table where dateadd(day,maxdate,shdate)

--dateadd()函数,DAY可直接加
---------------------------------------------------------------

SELECT * FROM table WHERE DATEDIFF(day, shdate, getdate()) > maxdate

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus