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.
I have a query that pulls data for the current month and last month. With the new year comes a problem with my query. I am using month(getdate())-1 to pull last months data but with the year now being 2006 it returns NULL or zero instead of December 2005. Any ideas how to fix this so the query will pull December 2005 for last month and future new years? I think this will only be a problem every January.Thanks,
TG
Master Smack Fu Yak Hacker
6065 Posts
Posted - 2006-01-03 : 14:18:33
Not sure what criterial you want but here is a where clause that will get all [myDate] values from previous month: