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

asp 时间的问题
做一个人才系统,查询时有个下拉菜单是时间范围,我设定的有2天内,一周内等,我的sql语句怎么写?  
时间字段:   adddate  
选定的时间范围变量是   :PostDate(传递的值是2、7等天数。)  
表名称是:jobs

------解决方案--------------------
SELECT * FROM jobs WHERE DATEDIFF(day, adddate, GETDATE()) <=2
SELECT * FROM jobs WHERE DATEDIFF(day, adddate, GETDATE()) <=7
------解决方案--------------------
PostDate=DateAdd(d,-PostDate,Now)
Access:
Sql= "Select * from jobs Where adddate> # "& PostDate & "# "
MSSQL:
Sql= "Select * from jobs Where adddate> ' "& PostDate & " ' "