Hello,
Selecting the last month's data and the last 30 days's data might not be the same thing.
Use the DATEADD function to subtract from today's date:
select DATEADD(month,-1,getdate())
select DATEADD(day,-30,getdate()))
Using the format "MMDDYY" is really not convenient. If you can change it, please do ! At least, use the "MM/DD/YY" which is easily recognized by SQL Server.
If you have to work with your format, you'll have to stuff two "/" into your string.
SELECT SUBSTRING(yourdate,1,2) + '/' + SUBSTRING(yourdate,3,2) + '/' + SUBSTRING(yourdate,5,2)
Finally, convert the newly formed string into a valid date :
select CONVERT(datetime,yourNewString,1)
You should end up with a select like this :
SELECT yourdata FROM yourtable
WHERE CONVERT(datetime,SUBSTRING(yourdate,1,2) + '/' + SUBSTRING(yourdate,3,2) + '/' + SUBSTRING(yourdate,5,2),1)
<= DATEADD(month,-1,getdate())