Click to See Complete Forum and Search --> : SQL query in ASP


mavrik_1983
08-06-2007, 09:48 AM
Hi, I am building a website in ASP and I am using MS SQL server 2005 as my database. My website is for online orders.
What I am now trying to do is to retrive the products from the database which are added within the last 4 weeks.
I dont know how should I go from here onwards in "WHERE" statement. What I want to do is something like this.

SQL = "SELECT *
FROM product
WHERE date_added = (current date minus 4 weeks)

Can anyone help me with this query

Cheers

Nandem
08-06-2007, 12:09 PM
SQL = "SELECT *
FROM product
WHERE date_added = DATEADD(DAY, -28, GETDATE())


cya

Terrorke
08-07-2007, 03:02 AM
make sure your date_added is of the type date in your database. Otherwise this won't work