I tried to use
SELECT * from Results
WHERE DATEDIFF(d,Date,getdate())<30
But it seem having error with this.
For each record submitted will only display 30 days. May I know if my syntax is correct?
Greatly Appreciated, Stan
Syntax looks OK, but you might need to 'quote' Date
:
SELECT * from Results WHERE DATEDIFF(d, [Date], getdate()) < 30
Do you have a column called Date in Results?
BTW, that won't be able to use an index, whereas this will:
SELECT * from Results WHERE [Date] >= DATEADD(d, -30, getdate())