asp classic - Would like SQL query that pulls the last 7 days of table data with ASP -
so i'm trying pull last 7 days of table data using sql within asp. think syntax incorrect
<% set rstest = server.createobject("adodb.recordset") sql = "select * divisionnew jms_updatetime between '" & date & "' , '" & date 7 & "'" rstest.open sql, db
%>
select * divisionnew jms_updatetime >= getdate()-7
or
select * divisionnew jms_updatetime >= dateadd(d,-7,getdate())
but if want absolute date (without caring time:
select * divisionnew jms_updatetime >= convert(datetime,convert(varchar,getdate())) - 7
or
select * divisionnew jms_updatetime >= dateadd(d,-7,convert(datetime,convert(varchar,getdate())))
if on sql server 2008 or later:
select * divisionnew jms_updatetime >= convert(date,getdate()) - 7
or
select * divisionnew jms_updatetime >= dateadd(d,-7,convert(date,getdate()))
Comments
Post a Comment