Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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 breakingnewswhere archive =0and category in (1,2)and datepart = dateadd('d', 30, upload_date)order by upload_date descThanks
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))