Better Filtering With YEAR and MONTH Functions In SQL Server
This week, I’ve got a coupon that offers an even steeper discount on my training than the one at the bottom of the post.
It brings the total cost on 24 hours of SQL Server performance tuning content down to just about $100 USD even. Good luck finding that price on those other Black Friday sales.
It’s good from December 23rd-27th, or until I remember to turn it off. Hurry along now.
Thanks for watching!
Going Further
If this is the kind of SQL Server stuff you love learning about, you’ll love my training. I’m offering a 75% discount to my blog readers if you click from here. I’m also available for consulting if you just don’t have time for that, and need to solve database performance problems quickly. You can also get a quick, low cost health check with no phone time required.
Thank you for this. I understand why it is better to use values for the lookup rather than using functions on the column values.
In regard to leap years, would it not be simpler to declare a @ToDate DATE variable, assign it to be the first day of the next month, and then use < in the query rather than <= [last day of the month]? Does using < negatively affect the execution plan? I also find that, in general, this has the added effect of selecting all dates in the month if any of the date values in the table have a time value.
Good work on these videos.
Hey — thanks! Yeah, I made this a little more complicated than I needed to in retrospect. I think as long as the query logically gets you the results you want, either one is fine.
Also, apologies for the late approval/response. This ended up in spam for some reason.