Click to See Complete Forum and Search --> : Last 30 days


Evie
03-30-2007, 10:03 AM
I don't know why I can't get the answer to this, you'd think it would be simple.

But it isn't.

I want to restrict the results of a query to the last 30 days. I came from FoxPro 5 and this used to work

Select * from [TABLE] where [DATECOLUMN] < 30

But it doesn't work with MS SQL Server 2005. I've spent the last 30 minutes on the MSDN site trying to find the answer to this, but to no avail.

Please help!

~ E

Evie
03-30-2007, 10:20 AM
Wow, finally found it. It wants the getdate() function.

mattyblah
03-30-2007, 02:56 PM
Use datediff(day, [datecolumn], getdate()) > 30, that should work.

Evie
03-30-2007, 03:00 PM
thank you!