Writing date-based queries with SQL Server are common in our industry. Writing good queries is likely less common. As a subscriber to the MS SQL Tips new letter, I frequently encounter useful information and helpful tips.
“Using a calendar table in SQL Server – Part 1” by Aaron Bertrand (2021-04-22) is particularly useful for creating a calendar table and using it for a variety of purposes. The article also discusses performance and enhancements to yield results efficiently and effectively.
If you use SQL Server as part of your job function, I highly recommend subscribing to MSSQLTIPS. When you think you know as much as there is to know, you quickly discover you don’t. My mantra, “There’s always a better way and more than one solution!,” continues to age well in this context.