Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi allhow can i get the report to run between start date of last month to last day of last monthfor examplereport run today but it will run for date between Feb 1 to Feb 28?thanks
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts
Posted - 2006-03-08 : 11:27:28
This will do it:
select *from MyTablewhere -- Greater than or equal to start of last month MyDateCol >= dateadd(mm,datediff(mm,0,getdate())-1,0) and -- Less than the start of current month MyDateCol < dateadd(mm,datediff(mm,0,getdate()),0)