SQL Query - select when date passed 7 days

JackTheKnife

Limp Gawd
Joined
Mar 27, 2006
Messages
272
Is it possible to create SQL query to select values when date from one filed passed 7 days gap?

Something like:

Code:
SELECT ID, Name, Title, date_run FROM tbl_test WHERE date_run+7days=now()

Thanks
 
SQL Server?

Specifically, at any time that you run this query on June 8, you want to display all titles that were filed between June 1 00:00:00.000 and June 1 23:59:59.999?


SELECT ID, Name, Title, date_run FROM tbl_test WHERE CONVERT(VARCHAR(10), date_run, 101) = CONVERT(VARCHAR(10), DATEADD(DAY,-7,GETDATE()), 101)
 
SQL Server?

Specifically, at any time that you run this query on June 8, you want to display all titles that were filed between June 1 00:00:00.000 and June 1 23:59:59.999?


SELECT ID, Name, Title, date_run FROM tbl_test WHERE CONVERT(VARCHAR(10), date_run, 101) = CONVERT(VARCHAR(10), DATEADD(DAY,-7,GETDATE()), 101)

Yes, SQL server and I'm using date not timestamp, so there is no time.
 
Yes, SQL server and I'm using date not timestamp, so there is no time.
Look into the DATEDIFF function.

And I don't believe you intended it, but be aware of a data type called TIMESTAMP; this has nothing to do with actual dates/times, but rather row versioning.
 
Back
Top