Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Reterving data

Author  Topic 

satheesh
Posting Yak Master

152 Posts

Posted - 2011-03-28 : 07:22:24
Hi All,

I want to reterview last year next month data.ie.I need data for the month April 2010

where (cst.DateCreated between '2010-04-01 00:00:00.000' AND '2010-04-30 23:59:59.997')

I can do like this, but i need to set as schedule report to generate every month.So i cant able to change the date in the query.

Any other possiblities?Any help would be highly appreciated

Regards,
SG

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-03-28 : 07:30:58
[code]where
cst.DateCreated >= dateadd(mm,datediff(mm,0,getdate())-11,0)
and cst.DateCreated < dateadd(mm,datediff(mm,0,getdate())-10,0)[/code]
Go to Top of Page

satheesh
Posting Yak Master

152 Posts

Posted - 2011-03-28 : 07:44:24
Thanks sunitabeck
Its working.
Go to Top of Page
   

- Advertisement -