Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query

Author  Topic 

hongho2
Starting Member

6 Posts

Posted - 2006-05-03 : 16:16:56
I have the table to collected all the information that submitted by users. One of the column call Upload_Date (dbo.DefDate). I want to run the query to get all the info within 30 days from the Upload_Date. Here what I have but it didn’t work.

select *
from breakingnews
where archive =0
and category in (1,2)
and datepart = dateadd('d', 30, upload_date)
order by upload_date desc

Thanks

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-05-03 : 16:46:28
this assumes you want all rows where update_date equal to or more recent than thirty days ago
and upload_date >= dateadd(day, -30, dateadd(day, datediff(day, 0, getdate()), 0))


Be One with the Optimizer
TG
Go to Top of Page

hongho2
Starting Member

6 Posts

Posted - 2006-05-03 : 16:51:18
It worked. Thankssssssss
Go to Top of Page
   

- Advertisement -