SQL Server ASPDiscussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
You have to have some FIELD in your TABLE that holds the date entered.
Databases do *NOT* do that automatically.
*ASSUMING* you have such a field:
SELECT * FROM mytable
WHERE theDateRecordWasAdded >= DATEADD(d,-7,getDate())
Now, the problem with that is that getDate() returns a date AND time, equivalent to NOW() in VB/VBScript. So that DATEADD will give you a date and time exactly 7 days ago as of this moment. If you want it to be 7 days ago, starting at midnight on that day, we have to get fancier.
But I won't go further until you tell me (a) you do have a field in your table that holds when the record was added, (b) whether that field holds a date-only or a date+time value, and (c) how you want to "cut off" the records [to the second or to the day].