Hi im still fairly new to SQL script and i have written some below to fetch what i hope will be ALL of the previous months data when run at any given date, regardless of the number of days in a month
The table date format is 2013-05-10 00:00:00.000
im just after an expert eye to look at the script and advise if i have got it right or wrong and where if i have please:
SELECT
[Circuit Number]
,[Request Number]
,[RequestDate]
FROM [QuoteBase].[dbo].[Requests]
WHERE RequestType LIKE 'Cancel%'
AND DATEPART(mm, [RequestDate]) = DATEPART(mm, DATEADD(mm, -1, getdate()))
AND DATEPART(yyyy, [RequestDate]) = DATEPART(yyyy, DATEADD(mm, -1, getdate()))