Craig Farrell (12/10/2010)
Plenty of hope, I've been at this ten years or so, Wayne longer. Give yourself time. Eventually you remember the functions offhand and then start coming up with strange and interesting ways to twist them together like burnt pretzels. 🙂
And, now that you understand what's going on here... you'll never forget it. So, you've been exposed to dateadd(datediff) to get the first of the month (change the datepart to get the first of any period!), and using reverse/stuff/reverse. Not too bad for one thread!
EDIT: Check out the common date/time routines link in my signature!
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes