*gnaws on Mouse cord* Recently reintroduced to querying SQL, and at an absolute loss on how to get it to only feed me records for the 12 months prior to the current month (last 12 full months in other words)based on a datetime field in the database. I can get it to do this year and last year, but that isn't what's required. Any help will be much appreciated. (This will eventually create a temp table for a stored procedure for a Crystal Report)
What I have thus far which gets me only records from 2004 and 2005, and is probably way off what I actually need to do:
What I have thus far which gets me only records from 2004 and 2005, and is probably way off what I actually need to do:
Code:
Select CREATED from dbo.S_SRV_REQ
WHERE Datename(yy,CREATED) BETWEEN Datename(yy,dateadd(yyyy,-1,GETDATE())) AND Datename(yy,GETDATE())